Thursday, 2 January 2014

How to fix issues where e.Row.Cells returns empty string while accessing gridview rows

 Watch this example on YouTube

REPLACE

 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                string test1 = e.Row.Cells[0].Text;
            }
        }
WITH
 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Label lb = (Label)e.Row.Cells[0].FindControl("Label1");
                string test2 = lb.Text;

            }
        }

2 comments:

  1. Thanks so much, You saved my day.

    ReplyDelete
  2. This article provides valuable troubleshooting tips for resolving issues with accessing GridView rows—very helpful for ASP.NET developers! If you're also a gamer, Skynode is a great tool to help you manage your game library while you refine your coding skills.

    ReplyDelete