Hi
I have followed AnandM's response to this post: https://www.aspforums.net/Threads/875362/Filter-GridView-with-multiple-DropDownList-in-HeaderTemplate-using-C-and-VBNet-in-ASPNet/Replies/2
I have adapted his solution to my own grid that contains 12 columns. I have added a drop down list to the second column. However, my code errors at the PopulateDropDown line with an 'Object reference not set to an instance of an object':
private void BindDropDownList()
{
TableCell cells = gv.HeaderRow.Cells[]
PopulateDropDown((cells.FindControl("ddlGroupName") as DropDownList), (cells.FindControl("lblGroupName") as Label).Text);
}
This is my HTML:
<asp:BoundField DataField="GroupID" HeaderText="Group ID" />
<asp:BoundField DataField="GroupCode" HeaderText="Group Code" />
<asp:TemplateField>
<HeaderTemplate>
<asp:Label ID="GroupName" Text="Group Name" runat="server" />
<asp:DropDownList ID="ddlGroupName" runat="server" OnSelectedIndexChanged="DropDownChange" AutoPostBack="true" ></asp:DropDownList>
</HeaderTemplate>
<ItemTemplate>
<asp:HiddenField ID="hfGroupName" runat="server" Value='<%# Eval("GroupName") %>' />
<%# Eval("GroupName") %>
</ItemTemplate>
</asp:TemplateField>
Any help would be most appreciated!