从gridview获取row null

时间:2017-06-26 03:00:50

标签: c# asp.net gridview

当我尝试调试时,我看到我的按钮为空。谁知道为什么?这是代码。提前谢谢!

protected void Delete_Click(object sender, EventArgs e)
{
    con.Open();
    Button btn = sender as Button;
    GridViewRow row = (GridViewRow)btn.NamingContainer;
    Label headerAthleteID = (Label)row.FindControl("lblAthleteID");
    con.Close();
}

这是我的网格视图部分

         <asp:TemplateField SortExpression="deleteColumn">
             <ItemTemplate>
                <asp:Button ID ="deleteButton" runat="server" Text="Delete" OnClick="Delete_Click" />
             </ItemTemplate>
         </asp:TemplateField>

0 个答案:

没有答案