I am trying to read gridview column through the following code

     protected void gdOrderdetails_RowUpdating(object sender, GridViewUpdateEventArgs e)
                 string name1;
      GridViewRow name = gdOrderdetails.SelectedRow;
        name1 = name.Cells[1].Text.ToString();



It's giving error "Object reference not set to an instance of an object."

Pls help me out

Thanks in advance

I had the same problem when updating a cell value on another comboboxcell change I really tried hell lot of things to solve that at the end I sorted it out by placing the cell updating code in timer_tick function and set the interval to 2 seconds i.e. after every two seconds my cell updated according to the current value in comboboxcell ... although it is a weak way but it worked for me ....

I think this would help u.

GridViewRow grdRow = gdrView.Rows[e.RowIndex];
            TextBox txtName = (TextBox)gdrView.Rows[e.RowIndex].FindControl("FirstName");

protected void gdrView_RowUpdating(object sender, GridViewUpdateEventArgs e)
            DataTable dt = (DataTable)Session["objDataTable"];

            GridViewRow grdRow = gdrView.Rows[e.RowIndex];

            TextBox txtName = (TextBox)gdrView.Rows[e.RowIndex].FindControl("FirstName");

            dt.Rows[grdRow.DataItemIndex]["FirstName"] = ((TextBox)(grdRow.Cells[1].Controls[0])).Text;
            dt.Rows[grdRow.DataItemIndex]["MiddleName"] = ((TextBox)(grdRow.Cells[2].Controls[0])).Text;
            dt.Rows[grdRow.DataItemIndex]["LastName"] = ((TextBox)(grdRow.Cells[3].Controls[0])).Text;
            ViewState["Dt"] = dt;
            gdrView.DataSource = dt;
            gdrView.EditIndex = -1;