private void BindDropDown() { using (SqlConnection con = new SqlConnection(@"Data Source=maj-056\sqlexpress;Initial Catalog=Sample;Integrated Security=True;Pooling=False")) { SqlCommand cmd = new SqlCommand("sp_select", con); cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); if (ds.Tables[0].Rows.Count > 0) { DropDownList1.DataSource = ds.Tables[0]; DropDownList1.DataTextField = ""; DropDownList1.DataValueField = ""; DropDownList1.DataBind(); DropDownList2.DataSource = ds.Tables[1]; DropDownList2.DataTextField = ""; DropDownList2.DataValueField = ""; DropDownList2.DataBind(); DropDownList3.DataSource = ds.Tables[2]; DropDownList3.DataTextField = ""; DropDownList3.DataValueField = ""; DropDownList3.DataBind(); } } }
create proc sp_select as begin select * from Table1 end begin select * from Table2 end begin select * from Table3 end
DataText
Select *
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)