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

前端 未结 7 1642
情深已故
情深已故 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:18

     protected void btnS10_click(object sender, EventArgs e)
        {
            foreach (GridViewRow row in Grd.Rows)
            {
                CheckBox chk_Single = (CheckBox)row.FindControl("ChkSendOne");
                if (row.RowType == DataControlRowType.DataRow)
                {
                    string id = (row.Cells[0].FindControl("lblSNo") as Label).Text;
                    if (Convert.ToInt32(id) <= 10)
                    {
                       
                        chk_Single.Checked = true;
                        if (chk_Single.Checked == true)
                        {
                            lblSelectedRecord.InnerText = (Convert.ToInt32(lblSelectedRecord.InnerText) + 1).ToString();
                        }
                    }
                }
            }
        }
    

提交回复
热议问题