Thursday, March 29, 2012

painfully ignorant but frustrating

I HAVE looked around but cant figure out the stupid mistake I'm
making. I am POSTing a form and in the CodeBehind function for the
submit i am simply building a SQL statement, however, I cant seem to
retrieve the correct (newly selected) values for the dropdownlist
controls. I'm sorry, i know this is elementary but I just cant see my
error - anyone give me the lowdown?!

SQL string below: (Im trying both the selected item & index but both
give the original value when first rendered)...

INSERT INTO Team " +
"(TeamName, Email, fkManufacturerId," +
"fkDriver1Id, fkDriver2Id, fkDriver3Id," +
"fkTyreId,Paid) " +
" VALUES " +
"('" + txtTeamName.Text + "'," +
"'" + txtUserId.Text + "'," +
ddlManufacturer.SelectedIndex + "," +
ddlDriver1.SelectedItem.Value + "," +
ddlDriver2.SelectedItem.Value + "," +
ddlDriver3.SelectedItem.Text + "," +
ddlTyre.SelectedItem.Value + "," +
"False);";

cheers, danTHANKYOU Corey! - Perfect answer and as i said, a real simple
(obvious) mistake which i just couldnt see!

Kind regards, dan
Your post went unanswered. Have you resolved this issue?

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"dan m" <dan@.grandprix.freeserve.co.uk> wrote in message
news:7ffa57ad.0402061535.746a3715@.posting.google.c om...
> I HAVE looked around but cant figure out the stupid mistake I'm
> making. I am POSTing a form and in the CodeBehind function for the
> submit i am simply building a SQL statement, however, I cant seem to
> retrieve the correct (newly selected) values for the dropdownlist
> controls. I'm sorry, i know this is elementary but I just cant see my
> error - anyone give me the lowdown?!
> SQL string below: (Im trying both the selected item & index but both
> give the original value when first rendered)...
> INSERT INTO Team " +
> "(TeamName, Email, fkManufacturerId," +
> "fkDriver1Id, fkDriver2Id, fkDriver3Id," +
> "fkTyreId,Paid) " +
> " VALUES " +
> "('" + txtTeamName.Text + "'," +
> "'" + txtUserId.Text + "'," +
> ddlManufacturer.SelectedIndex + "," +
> ddlDriver1.SelectedItem.Value + "," +
> ddlDriver2.SelectedItem.Value + "," +
> ddlDriver3.SelectedItem.Text + "," +
> ddlTyre.SelectedItem.Value + "," +
> "False);";
> cheers, dan

0 comments:

Post a Comment