I wanted to populate a gridview from codebehind. The data comes from
10 different tables.
The table from which data is to be taken is chosen using a
dropdownlist.
I needed to update some of the fields shown on the gridview.
The no. of fields will be different for different tables.
Also, one of the fields in 6 of these tables must display a dropdown
list, for editing.
Can somebody help me..?
You can dynamically update the Select command of your SQLDataSource
depending on which drop-down value you select.
The GridView should be set to auto-generate the columns.
Example:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs
e)
{
SqlDataSource1.SelectCommand = DropDownList1.SelectedValue;
}
For this example, I put the SQL string in the value of the DropDownList
item. For security reasons, you probably want to assign a string
programmatically using a switch structure to avoid SQL injection attacks.
I think that you will have to add in the DropDownField afterwards through
code, but am not quite sure how to go about this. Perhaps someone else will
jump in here with a clever suggestion.
HTH
Steve
"chacal" <rohin...@gmail.com> wrote in message
news:3fe0a017-8964-41e6...@i24g2000prf.googlegroups.com...