Monday 15 February 2010

c# - DropDownList with Two SqlDataSources -


I have a dropdown list with EnableAutoPostBack and two SqlDataSources.

What am I trying to do if the user chooses the radiobuttonRed then DDLType will use SqlDataSourceRed and performance data in a gridview based on the selected DDLTYpe item.

If the user selects radiobuttonBlue, then select DDLType SqlDataSourceBlue and will display data in a gridview based on the DDLTYpe item.

How can I achieve this goal?

After the

you will need two SqlConnection items in each database with a connection string:

  SqlConnection connRed = new SqlConnection (); SqlConnection connBlue = New SqlConnection (); Datatile dt = faucet; SqlDataAdapter da = null; If (radio button check) {dt = new DataTable (); Da = new SqlDataAdapter ("select command", connRed); } Else {dt = New DataTable (); Da = new SqlDataAdapter ("select command", connBlue); } D.Fill (DT); Dgv.DataSource = dt; Dgv.DataBind ();    

No comments:

Post a Comment