473,320 Members | 2,073 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,320 software developers and data experts.

Cannot access data row in Repeater ItemCommand event

Hello,

I am trying to determine the proper way to access the underlying data row
for a Repeater item in the ItemCommand event. In the page load event, I bind
the Repeater data source to a SqlDataReader. I check for !IsPostBack so the
data binding only happens the first time.

In the ItemCommand event, e.Item.DataItem is unassigned. Any suggestions?
Thanks!
Nov 19 '05 #1
3 10895
"Joel Daniels" <Jo*********@discussions.microsoft.com> wrote in message
news:FA**********************************@microsof t.com...
Hello,

I am trying to determine the proper way to access the underlying data row
for a Repeater item in the ItemCommand event. In the page load event, I
bind
the Repeater data source to a SqlDataReader. I check for !IsPostBack so
the
data binding only happens the first time.

In the ItemCommand event, e.Item.DataItem is unassigned. Any suggestions?


It's supposed to be unassigned. What would it be set to? There's no data on
post back!

If you supply the DataKey property property to the DataGrid when you
DataBind it, then you can use the ItemIndex of the RepeaterItem to index
into the DataKeys property of the DataGrid. Given the primary key of the
DataRow which originally loaded that Repeater item, you can load it again.

John Saunders
Nov 19 '05 #2
I'm working with a repeater, not a datagrid. There is no DataKey property
that I can see.

Since data binding only happens one time, I may need to either store a data
value in a hidden field on the item template or else use the value for a
CommandArgument.
"John Saunders" wrote:
"Joel Daniels" <Jo*********@discussions.microsoft.com> wrote in message
news:FA**********************************@microsof t.com...
Hello,

I am trying to determine the proper way to access the underlying data row
for a Repeater item in the ItemCommand event. In the page load event, I
bind
the Repeater data source to a SqlDataReader. I check for !IsPostBack so
the
data binding only happens the first time.

In the ItemCommand event, e.Item.DataItem is unassigned. Any suggestions?


It's supposed to be unassigned. What would it be set to? There's no data on
post back!

If you supply the DataKey property property to the DataGrid when you
DataBind it, then you can use the ItemIndex of the RepeaterItem to index
into the DataKeys property of the DataGrid. Given the primary key of the
DataRow which originally loaded that Repeater item, you can load it again.

John Saunders

Nov 19 '05 #3
I'm working with a repeater, not a datagrid. There is no DataKey property
that I can see.

Since data binding only happens one time, I may need to either store a data
value in a hidden field on the item template or else use the value for a
CommandArgument.
"John Saunders" wrote:
"Joel Daniels" <Jo*********@discussions.microsoft.com> wrote in message
news:FA**********************************@microsof t.com...
Hello,

I am trying to determine the proper way to access the underlying data row
for a Repeater item in the ItemCommand event. In the page load event, I
bind
the Repeater data source to a SqlDataReader. I check for !IsPostBack so
the
data binding only happens the first time.

In the ItemCommand event, e.Item.DataItem is unassigned. Any suggestions?


It's supposed to be unassigned. What would it be set to? There's no data on
post back!

If you supply the DataKey property property to the DataGrid when you
DataBind it, then you can use the ItemIndex of the RepeaterItem to index
into the DataKeys property of the DataGrid. Given the primary key of the
DataRow which originally loaded that Repeater item, you can load it again.

John Saunders

Nov 19 '05 #4

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

Similar topics

0
by: hendrik.vanniekerk | last post by:
Hi I'm using a repeater control doing databinding to an array at runtime. I have created a Template class for creating Headertemplate Itemtemplate etc. creating databinding at runtime. It...
0
by: bill yeager | last post by:
I have a datalist displaying parent information and a datagrid presenting child information. The data is being rendered just fine. The datagrid has template columns on it that I cannot gain access...
0
by: Patrik Persson | last post by:
Hello all I have got a problem with a nested repeater and the ItemCommand Event. I am adding handler for the ItemCommand and ItemBound. The ItemBound works perfect but I cant seem to get the...
3
by: Piotr Strycharz | last post by:
Hi, I have a Repeater with CheckBox in one of its columns. In ItemDataBound handler I'm doing: chk.CheckedChanged += new EventHandler(chk_CheckedChanged). The chk_CheckedChanged handler is...
3
by: Leigh Webber | last post by:
I have an HTMLAnchor control on my aspx page. When it's not inside a repeater, it works fine. When I put it inside a repeater control, the handler never gets fired. I have a handler for the...
2
by: Curt_C [MVP] | last post by:
I've got a Repeater and within it a LinkButton. The LinkButton has an CommandName="Test" In the Repeater's ItemCommand event I want to check for this command name but the problem I'm having is...
0
by: riddion | last post by:
Hello. I am having problems with the repeater webform control. Inside the <ItemTemplate> section I have a Calendar control. This is for so the user can choose a different date on each of the...
6
by: =?Utf-8?B?U2FuZHBvaW50R3V5?= | last post by:
In the datagrid I would put key values (that I didnt want to display) in columns marked not visible, in the gridview I would put them in datakeys. Im need to apply greater control over my html, so...
2
by: Nathan Sokalski | last post by:
I have an ImageButton inside a Repeater control. However, the ImageButton does not trigger the Repeater's ItemCommand event. For the moment, I am nesting an Image control inside a LinkButton, which...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.