0

I am accessing a TextField within a GridView. It shouldn't pick the updated text, instead, it takes the original text only. I am using two GridViews within the same page in different tabs. Will that make them affect each other?

But the GridView is giving me an exception:

An exception of type 'System.NullReferenceException' occurred in OnlineExamDesign.dll but was not handled in user code. Additional information: Object reference not set to an instance of an object.

else if (e.CommandName == "UpdateRowTeam")
            {
                DomainTeam updateObj = new DomainTeam();
                int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
                int index = Convert.ToInt32(e.CommandArgument);
                string name = ((TextBox)domainGrid.Rows[rowIndex].FindControl("txtchangeTeamName")).Text;
                updateObj.actionTeam(index,name,"TeamUpdate");
                teamGrid.EditIndex = -1;
                getTeamGridData();
            }
devRicher
  • 428
  • 1
  • 7
  • 21
Anjan Rane
  • 11
  • 3
  • Possible duplicate of [What is a NullReferenceException, and how do I fix it?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – devRicher Jan 20 '17 at 07:36
  • 2
    Anjan, Please share whole code this block of code is not sufficient to understand the problem. – Rashmi Saini Jan 20 '17 at 07:44
  • Chances are there is no TextBox named `txtchangeTeamName`. – VDWWD Jan 20 '17 at 08:30

1 Answers1

0

Try This Code :

GridViewRow row = (GridViewRow)((Button)sender).NamingContainer;
 TextBox TextBox1 = row.FindControl("TextBox1") as TextBox; 

  string myString = TextBox1.Text; //Access TextBox1 here.
Karthik_SD
  • 633
  • 1
  • 6
  • 22