i have a one drop down list containing the list of items. each item is further connecting to different table. there is gridview that show the sel开发者_JAVA技巧ected table by selecetd item in drop down list. how is it possible? that to show the selected table f
gridView.DataSource = tableCollection[dropDownList.SelectedValue];
You can use this for your dropdown in your gridview.
<asp:TemplateField HeaderText="Item Condition" HeaderStyle-Width="80px" HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="40px>
<ItemTemplate>
<asp:DropDownList ID="ddlConditions" runat="server" >
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
Under your grid "RowDataBound" event, you will bind your dropdown in code behind using dropdown id.
DropDownList ddlConditions2 = (e.Row.FindControl("ddlConditions") as DropDownList);
DataTable dt = _reader.GetDataTableByCommandFromStoredProc("getYourDropdownData");
ddlConditions2.DataSource = dt;
ddlConditions2.DataTextField = "ConditionName";
ddlConditions2.DataValueField = "Id";
ddlConditions2.DataBind();
ddlConditions2.Items.Insert(0, new ListItem("--Select--", "0"));
精彩评论