GridView error

G

Guest

Hi Guys,

I have a link button in TemplateField in a gridview called
"transactionListGridView" and when tying to run this:
protected void transactionListGridView_RowCommand(object sender,
GridViewCommandEventArgs e)
{
if (e.CommandName=="select")
{

string transactionID =
transactionListGridView.SelectedRow.Cells[1].Text;
messageLabel.Visible = true;
messageLabel.Text = xx;
}
}

it gives me this error message: "Object reference not set to an instance of
an object" do U know what could be the problem!!?


Cheers Guys.
 
G

Guest

Its probably that the Row Selection hasnt taken place yet so
transactionListGridView.SelectedRow is null. You will probably need to get
the row index from the event args and select the row from the rows collection.

Ciara O'Donnell
 
G

Guest

Hi,

it's this line that's raised the error "string transactionID =
transactionListGridView.SelectedRow.Cells[1].Text;"
could U explain to me what U denoted by getting the row index from the event
args!!?
What I'm trying to do is getting the Value of a specific cell when a row is
selected

Ciaran O''Donnell said:
Its probably that the Row Selection hasnt taken place yet so
transactionListGridView.SelectedRow is null. You will probably need to get
the row index from the event args and select the row from the rows collection.

Ciara O'Donnell

Badis said:
Hi Guys,

I have a link button in TemplateField in a gridview called
"transactionListGridView" and when tying to run this:
protected void transactionListGridView_RowCommand(object sender,
GridViewCommandEventArgs e)
{
if (e.CommandName=="select")
{

string transactionID = transactionListGridView.SelectedRow.Cells[1].Text;
messageLabel.Visible = true;
messageLabel.Text = xx;
}
}

it gives me this error message: "Object reference not set to an instance of
an object" do U know what could be the problem!!?


Cheers Guys.
 

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