Object reference not set to an instance of an object

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I'm having this error "Object reference not set to an instance of an object"
while running this event in my transactionListGridView control.
protected void transactionListGridView_SelectedIndexChanged(object sender,
EventArgs e)
{
string xx = transactionListGridView.SelectedRow.Cells[0].Text;
messageLabel.Visible = true;
messageLabel.Text = xx;
}

Thnks guys.
 
Badis said:
Hello,

I'm having this error "Object reference not set to an instance of an
object"
while running this event in my transactionListGridView control.
protected void transactionListGridView_SelectedIndexChanged(object sender,
EventArgs e)
{
string xx = transactionListGridView.SelectedRow.Cells[0].Text;
messageLabel.Visible = true;
messageLabel.Text = xx;
}

I'd guess Selected row is null.
 
Hi,

It means that one of the instances is null, it can be
transactionListGridView

or

transactionListGridView.SelectedRow

or

transactionListGridView.SelectedRow.Cells[0]

My bet is also in SelectedRow, if this is the first selection you do you had
no previously selection hence the error
 
Back
Top