3
Answers

Find Grid View Header Template Using A Button Click

sunil sharma

sunil sharma

12y
7.8k
1
        <asp:GridView ID="gridviewStock" runat="server" AutoGenerateColumns="false">
        <Columns>
            <asp:TemplateField>
                <HeaderTemplate>
                    <asp:DropDownList ID="ddlstCol1" runat="server">
                        <asp:ListItem>SRNO</asp:ListItem>
                        <asp:ListItem>Part</asp:ListItem>
                        <asp:ListItem>Part Deccription</asp:ListItem>
                        <asp:ListItem>UoM</asp:ListItem>
                        <asp:ListItem>Sales Price/UMRP</asp:ListItem>
                        <asp:ListItem>Purchase Price</asp:ListItem>
                        <asp:ListItem>Group</asp:ListItem>
                        <asp:ListItem>Rate Of Vat</asp:ListItem>
                        <asp:ListItem>Qty</asp:ListItem>
                    </asp:DropDownList>
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblCol1" runat="server" Text='<% #Eval("Col0") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>

i am bind Grid View and Find Control in a button Click
    protected void btnConfigure_Click(object sender, EventArgs e)
    {
        foreach (GridViewRow rowItem in gridviewStock.Rows)
        {
            DropDownList ddl = (DropDownList)(rowItem.Cells[0].FindControl("ddlstCol1"));
            DropDownList ddl1 = (DropDownList)(rowItem.Cells[1].FindControl("ddlstCol1"));
            DropDownList ddl2 = (DropDownList)(rowItem.Cells[2].FindControl("ddlstCol1"));
        }
    }
but this code not work


Answers (3)