2013-06-27 41 views
0

我想要在我的GridView标题和该标题行的复选框字段中的按钮。GridView中的按钮标题和复选框字段asp.net

我希望下面的代码可以工作。但是,这不起作用。我只看到头文件中的“删除”文本,当我点击它时什么也没有发生。

我做错了什么?

<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="false" CellPadding="4" ForeColor="#333333" 
        GridLines="None" OnRowCommand="Gridview2_RowCommand"> 
        <Columns> 

        <asp:BoundField DataField="fname" HeaderText="First Name" /> 
        <asp:BoundField DataField="mname" HeaderText="Middle Name" /> 
        <asp:BoundField DataField="lname" HeaderText="Last Name" /> 
        <asp:TemplateField HeaderText="Remove"> 
        <ItemTemplate> 

        <asp:CheckBox ID="checkselect" runat="server" /> 

        </ItemTemplate> 
        <asp:HeaderTemplate> 

        <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Split">sort</asp:LinkButton> 

        </asp:HeaderTemplate> 
        </asp:TemplateField> 
        </Columns> </Gridview> 

的即使行命令

protected void Gridview2_RowCommand(object sender, GridViewCommandEventArgs e) 
    { 
     if (e.CommandName == "Split") 
     { 
      Response.Write("I was clicked"); 
     } 
    } 

有人可以帮助我?

+0

它工作正常....你可能没有看到文本只有bcz的gridview隐藏.... –

+0

Gridview隐藏? – Huzaifa

+0

我没有把它藏在任何地方。 – Huzaifa

回答

0

我使用了错误的标签前缀。标题模板只是

<HeaderTemplate> not <asp:HeaderTemplate> 
相关问题