R
Reddy
I am trying to prepopulate two drop down meus with results of two differnt
SQL queries. I have written the following code. But I am getting errors. Can
anybody please help me how to do this. I also doubt whether this is the most
efficient way to have maximum performance when lots of users access the web
site.
string dsn = ConfigurationSettings.AppSettings["testDsn"];
SqlConnection connection = new SqlConnection (dsn);
SqlDataAdapter adapter = new SqlDataAdapter ("select * from authors; select
* from publishers", connection);
DataSet ds = new DataSet ();
adapter.Fill (ds, "authors");
DropDownList1.DataSource = ds;
DropDownList1.DataTextField = "au_fname";
DropDownList1.DataValueField = "au_id";
DropDownList1.DataBind ();
DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf
(DropDownList1.Items.FindByValue ("672-71-3249"));
DataSet ds2 = new DataSet ();
adapter.Fill (ds2, "publishers");
DropDownList2.DataSource = ds2;
DropDownList2.DataTextField = "pub_name";
DropDownList2.DataValueField = "pub_id";
DropDownList2.DataBind ();
DropDownList2.SelectedIndex = DropDownList2.Items.IndexOf
(DropDownList2.Items.FindByValue ("1389"));
Thanks,
Reddy
SQL queries. I have written the following code. But I am getting errors. Can
anybody please help me how to do this. I also doubt whether this is the most
efficient way to have maximum performance when lots of users access the web
site.
string dsn = ConfigurationSettings.AppSettings["testDsn"];
SqlConnection connection = new SqlConnection (dsn);
SqlDataAdapter adapter = new SqlDataAdapter ("select * from authors; select
* from publishers", connection);
DataSet ds = new DataSet ();
adapter.Fill (ds, "authors");
DropDownList1.DataSource = ds;
DropDownList1.DataTextField = "au_fname";
DropDownList1.DataValueField = "au_id";
DropDownList1.DataBind ();
DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf
(DropDownList1.Items.FindByValue ("672-71-3249"));
DataSet ds2 = new DataSet ();
adapter.Fill (ds2, "publishers");
DropDownList2.DataSource = ds2;
DropDownList2.DataTextField = "pub_name";
DropDownList2.DataValueField = "pub_id";
DropDownList2.DataBind ();
DropDownList2.SelectedIndex = DropDownList2.Items.IndexOf
(DropDownList2.Items.FindByValue ("1389"));
Thanks,
Reddy