E
Elsa Luiz
Hi,
I would like to access the value of a third field of the query that I
used to populate my dropdown list. Is there a way to do that? For
example, in the following example I would like to access valueC.
SqlCommand sqlCmdLoad1 = new SqlCommand("SELECT valueA, valueB, valueC
FROM myTable", sqlConnection1);
sqlConnection1.Open();
SqlDataReader dr1 = sqlCmdLoad1.ExecuteReader();
ddl.DataSource = dr1;
ddl.DataTextField = "valueA";
ddl.DataValueField = "valueB";
ddl.DataBind();
dr1.Close();
sqlConnection1.Close();
I know that to access valueA I would use: ddl.SelectedItem.Text for
example, to access valueB I would use: ddl.SelectedValue, and to
access valueC, is there any way?
Thanks,
Elsa
I would like to access the value of a third field of the query that I
used to populate my dropdown list. Is there a way to do that? For
example, in the following example I would like to access valueC.
SqlCommand sqlCmdLoad1 = new SqlCommand("SELECT valueA, valueB, valueC
FROM myTable", sqlConnection1);
sqlConnection1.Open();
SqlDataReader dr1 = sqlCmdLoad1.ExecuteReader();
ddl.DataSource = dr1;
ddl.DataTextField = "valueA";
ddl.DataValueField = "valueB";
ddl.DataBind();
dr1.Close();
sqlConnection1.Close();
I know that to access valueA I would use: ddl.SelectedItem.Text for
example, to access valueB I would use: ddl.SelectedValue, and to
access valueC, is there any way?
Thanks,
Elsa