473,471 Members | 4,648 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DataItem property = NULL during paging, why??!

Art
I'm subscribing to the RowCreated event during GridView render process to
modify properties of individual rows. All works great when there is no paging
involved but once I specify that I'd like to use paging my code works only on
the first page.
Please look at the code; when the first page loads ID is set properly (for
each row) but when you navigate to another one you'd get NullReference error.
Why, I don't get it??

Sample pseudo-code:
void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
int ID = ((DataRowView)e.Row.DataItem)["UserID"]
}
}
May 4 '06 #1
1 1756
Art
I was accessing DataItem property in respoonse to a wrong event
(RowCreated). DataItem property is only available in RowDataBound event which
fires before RowCreated event. Responding to this event allows me to examine
individual values in each row without running to the issue described in my
previous post. Thanks.

"Art" wrote:
I'm subscribing to the RowCreated event during GridView render process to
modify properties of individual rows. All works great when there is no paging
involved but once I specify that I'd like to use paging my code works only on
the first page.
Please look at the code; when the first page loads ID is set properly (for
each row) but when you navigate to another one you'd get NullReference error.
Why, I don't get it??

Sample pseudo-code:
void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
int ID = ((DataRowView)e.Row.DataItem)["UserID"]
}
}

May 4 '06 #2

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

Similar topics

2
by: Joel Lyons | last post by:
The help pages make it look like the DataGridItem.DataItem property would return a row from the bound table. Like so: //(during setup) myGrid.DataSource = myDataset.MyTable; myGrid.DataBind();...
1
by: rhungund | last post by:
Hi all...I have a stored proc that works fine except I can't get the paging property to work in ASP. It seems that because I'm building the SQL withing the SP is causing the problem. If I don't...
15
by: Laser Lu | last post by:
Hi, all, I was tangled by the DataGridItem.DataItem property. I tried to invoke that property to get and display the contents that was bound to the currently selected row. However, an exception...
1
by: Bresco | last post by:
I'm using ObjectDatasource in combination with a Formview. The ObjectDatasource is connected to a FormView. I have a business object property which I can't update through the normal binding...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.