473,387 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

GridView error

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.

Sep 12 '06 #1
3 1971
What line throws the exception?

Ciaran O'Donnell

"Badis" wrote:
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.
Sep 12 '06 #2
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" wrote:
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.
Sep 12 '06 #3
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" wrote:
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" wrote:
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.
Sep 12 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: W. Kacy | last post by:
I am having trouble using XML in an ASP.NET 2.0 webform. Using ASP.NET 2.0 beta 2, I have created a blank web page in a C# website. I have added an XML file (soData.xml), structured as follows: ...
8
by: Mike Kelly | last post by:
I've chosen to implement the "optimistic concurrency" model in my application. To assist in that, I've added a ROWVERSION (TIMESTAMP) column to my main tables. I read the value of the column in my...
1
by: James Rosewell | last post by:
I'm getting an error in the following scenario. - A GridView control is bound to an SQLDataSource. - The user selects a column for sorting. - Some time later in code the column used for sorting...
0
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this...
1
by: mitchman10 | last post by:
My Time table has TimeID,Employee,PayPeriod,ChargeCodeID,Hours My Chargecode table has ChargecodeID,c_Text I need an Editable datagrid that will show the TimeID,Employee,PayPeriod,C_Text in a...
3
by: =?Utf-8?B?bWFuaWthMDI=?= | last post by:
Hi, I have a GridView control in page called eventslisting which is inheriting from a MasterPage. The normal code to export to GridView does not work and gives me an error - "Control of type...
3
by: Dariusz Tomon | last post by:
Hello, I have GridView in EditItem Template of DetailsView (in normal - read-only mode there is a label). When I'm in edit mode I can select one item from GridView. The main problem is that as...
2
by: Blasting Cap | last post by:
I've got a gridview (that I converted over from a datagrid, which had been working properly), that is doubling up the number of rows returned. When it was running as a datagrid, the same code sent...
0
by: Paul | last post by:
In GridView if I make the CommandArgument of a link button a string created from something like myGuid.ToString() the RowCommand handler dies with an error I can't track down. The only thing I know...
0
by: =?Utf-8?B?ZWdzZGFy?= | last post by:
Hi, I have created a second gridview when customer clicks on select link with this code: Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.