473,320 Members | 1,930 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.

Problem with e.item.dataitem in OnItemDataBound

Hi all,

I have a simple scenario where I simply bien a repeater to a
datasource. Here's my repeater definition :

<asp:Repeater id="rTitles" runat="server" EnableViewState="false"
OnItemDataBound="Bind">
<headertemplate>
<ul>
</headertemplate>
<itemtemplate>
<li>
<%#Eval("str1")%>
</li>
</itemtemplate>
<footertemplate>
</ul>
</footertemplate>
</asp:Repeater>

So each time an item is bound, "Bind" is called, which looks like that
(just for testing) :

Protected Sub Bind(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.RepeaterItemEventArgs)
Dim drv As DataRowView = r.DataSource = e.Item.DataItem
End Sub

Well, "e.Item.DataItem" is always null (nothing) and that's my question
: WHY? Because when I put the single line in Bind in comment, my
repeater has all its data displayed, as if each row has a correct
dataitem. Why is my dataitem always null only in the ItemDataBound
method?

Thank you very much,

ibiza

Feb 1 '06 #1
2 3433
e.Item.DataItem will be null when e.Item.ItemTemplate is the HEaderTemplate
or FooterTemplate. You should check to see if you're in the footer/header
first, and if not try to access e.Item.DataItem.

Also, you clearly have option strict off, you should turn it on, you might
see some bugs in your actual line...not sure..I never know how operator
precedence works in VB :)

Karl
--
http://www.openmymind.net/

"ibiza" <la******@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Hi all,

I have a simple scenario where I simply bien a repeater to a
datasource. Here's my repeater definition :

<asp:Repeater id="rTitles" runat="server" EnableViewState="false"
OnItemDataBound="Bind">
<headertemplate>
<ul>
</headertemplate>
<itemtemplate>
<li>
<%#Eval("str1")%>
</li>
</itemtemplate>
<footertemplate>
</ul>
</footertemplate>
</asp:Repeater>

So each time an item is bound, "Bind" is called, which looks like that
(just for testing) :

Protected Sub Bind(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.RepeaterItemEventArgs)
Dim drv As DataRowView = r.DataSource = e.Item.DataItem
End Sub

Well, "e.Item.DataItem" is always null (nothing) and that's my question
: WHY? Because when I put the single line in Bind in comment, my
repeater has all its data displayed, as if each row has a correct
dataitem. Why is my dataitem always null only in the ItemDataBound
method?

Thank you very much,

ibiza

Feb 1 '06 #2
errr, thank you

I added the correct "if" and it works. As the two "=" on the same line,
it's obviously not good to have that "= r.DataSource", *#*%&
copy-paste...

Thanks!

Feb 1 '06 #3

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

Similar topics

1
by: Antonio D'Ottavio | last post by:
Good morning, I've a problem with a dropdownlist located inside any row of a datalist, I fill both datalist and dropdownlist at runtime, the problem is with the dropdownlist infact using the event...
3
by: Martin Høst Normark | last post by:
Hi everyone I get a System.NullReferenceException performing this code: public void Item_Bound(object sender, DataListItemEventArgs e) { if((int)(e.Item.DataItem as DataRowView).Row != 0) {...
1
by: Steven | last post by:
I have 2 different data grids that are storing data from two different tables in my data base: My datagrid starts like this: <asp:DataGrid id="DataGridGPA" runat="server"...
2
by: Stephen Miller | last post by:
I am using the OnItemDataBound event of Repeater control to nest a DataGrid within the Repeater. When I attempt to bind to the DataGrid using the DataSource method I get the error message "Object...
8
by: I am Sam | last post by:
Hi everyone, This problem is making me old. I don't want to get any older. I have a multi-nested repeater control as follows: <asp:Repeater ID="clubRep1" Runat="server">...
4
by: Girish | last post by:
Im trying to create a grid within a grid programmatically. Ive been successful in doing this but I need the embedded grid to fire its ItemDataBound event so I can handle it. The event does not seem...
7
by: Girish | last post by:
OK.. phew. Playing with data grids for the past few days has been fun and a huge learning experience.. My problem. I have a requirement to display a gird with a gird. Within the embedded grid,...
0
by: ElGordo | last post by:
I've been searching all over and think I am close, but keep getting the error "Index out of range" when trying to reference a nested datagrid when an OnEditCommand event is raised. When the...
1
by: Mikeon | last post by:
Hello! I have a problem customizing the databound controls using the OnItemDataBound event. The code below is an example of what I'm trying to do. I have a datasource and basing on the data I...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.