Object reference not set to an instance of an object

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.
 
M

Michael C

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.
 
I

Ignacio Machin \( .NET/ C# MVP \)

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top