How to get row data by clicking a button in a row in an ASP.NET gridview

前端 未结 7 1662
情深已故
情深已故 2020-12-09 08:56

I have a GridView in a ASP.NET web application, in which I have added two buttons in each row:

 

        
7条回答
  •  隐瞒了意图╮
    2020-12-09 09:09

    Place the commandName in .aspx page

     
    

    Subscribe the rowCommand event for the grid and you can try like this,

    protected void grdBillingdata_RowCommand(object sender, GridViewCommandEventArgs e)
    {
            if (e.CommandName == "DeleteData")
            {
                GridViewRow row = (GridViewRow)(((Button)e.CommandSource).NamingContainer);
                HiddenField hdnDataId = (HiddenField)row.FindControl("hdnDataId");
             }
    }
    

提交回复
热议问题