473,748 Members | 3,604 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing RepeaterItem.Da taItem in nested repeaters

Hello all!

I couldn't find a web application-newsgroup for ASP.NET, so I'm sorry if
this is the wrong forum!

Synopsis:
In my webform I have 3 nested repeaters:

rpWeeks
----- rpTime
---------- rpClasses

I am databinding the first repeater in the !IsPostBack event of the page,
and the data is coming from a Typed Dataset. The next repeater is DataBound
on its parent's "ItemDataBo und"-event and so on:

private void rpWeeks_ItemDat aBound(object sender, RepeaterItemEve ntArgs e)
{
Repeater rpTime = (Repeater)e.Ite m.FindControl(" rpTime");
rpTime.ItemData Bound += new
RepeaterItemEve ntHandler(rpTim e_ItemDataBound );
//And here is the code to bind the rpTime-repeater, although I've left it
out for simplicity
}

private void rpTime_ItemData Bound(object sender, RepeaterItemEve ntArgs e)
{
//Same thing here.. Getting the repeater and binding
}

All this works perfectly!

However, inside the rpClasses-repeater (the last one) I have a CheckBox with
an OnCheckedChange d-event and AutoPostBack=Tr ue:

//This event will fire, but RepeaterItem.Da taItem is NULL on PostBack !
public void c_CheckedChange d(object sender, EventArgs e)
{
CheckBox c = (CheckBox)sende r;
RepeaterItem r = (RepeaterItem)c .Parent;
balletDataset.c lassnameRow _cnr = (balletDataset. classnameRow)r. DataItem;
//r.DataItem is NULL on each
postback and the application will stop!
Response.Write( _cnr.teacher
+ "<br>");
}

I'm pretty sure that this is a state/event-problem, but what can I do to
solve it? I need to have access to the DataItem of the RepeaterItem because I
have to know what values were selected by the user!

I really hope that someone can help me with this one!

Thanks in advance,

Thomas.
Nov 16 '05 #1
3 14727
Hi,

microsoft.publi c.dotnet.framew ork.aspnet

is the NG for asp.net

Now regarding your problem I have never used that construction, I do agree
with you that it should be a state problem, but how to find it and correct
it I frankly have no idea.

A possible workaround would be if you use a hidden html control and set the
ID or PK of the datarow in it, then in the postback event handler you know
which was selected.

It would not be perfect but will certainly solve your problem.

What is happening in my opinion is that the inners repeaters are dynamic
controls, hence they needs to be recreated on each postback, how expensive
this is I have no idea really. but you could give it a try.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"DonRex" <Do****@discuss ions.microsoft. com> wrote in message
news:A2******** *************** ***********@mic rosoft.com...
Hello all!

I couldn't find a web application-newsgroup for ASP.NET, so I'm sorry if
this is the wrong forum!

Synopsis:
In my webform I have 3 nested repeaters:

rpWeeks
----- rpTime
---------- rpClasses

I am databinding the first repeater in the !IsPostBack event of the page,
and the data is coming from a Typed Dataset. The next repeater is
DataBound
on its parent's "ItemDataBo und"-event and so on:

private void rpWeeks_ItemDat aBound(object sender, RepeaterItemEve ntArgs e)
{
Repeater rpTime = (Repeater)e.Ite m.FindControl(" rpTime");
rpTime.ItemData Bound += new
RepeaterItemEve ntHandler(rpTim e_ItemDataBound );
//And here is the code to bind the rpTime-repeater, although I've left it
out for simplicity
}

private void rpTime_ItemData Bound(object sender, RepeaterItemEve ntArgs e)
{
//Same thing here.. Getting the repeater and binding
}

All this works perfectly!

However, inside the rpClasses-repeater (the last one) I have a CheckBox
with
an OnCheckedChange d-event and AutoPostBack=Tr ue:

//This event will fire, but RepeaterItem.Da taItem is NULL on PostBack !
public void c_CheckedChange d(object sender, EventArgs e)
{
CheckBox c = (CheckBox)sende r;
RepeaterItem r = (RepeaterItem)c .Parent;
balletDataset.c lassnameRow _cnr = (balletDataset. classnameRow)r. DataItem;
//r.DataItem is NULL on
each
postback and the application will stop!

Response.Write( _cnr.teacher
+ "<br>");
}

I'm pretty sure that this is a state/event-problem, but what can I do to
solve it? I need to have access to the DataItem of the RepeaterItem
because I
have to know what values were selected by the user!

I really hope that someone can help me with this one!

Thanks in advance,

Thomas.

Nov 16 '05 #2
Ignacio,

Thanks for your help!
Now regarding your problem I have never used that construction
Well.. If you've never used this construction before, what construction do
you use then? To me, this is the most "straight-forward" approach I could
think of using nested repeaters, but I may be wrong, and am more than willing
to learn!

And thanks for pointing out the correct newsgroup! I'll use that for any
further problems I run into! ;)

Thanks in advance,

Thomas

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

microsoft.publi c.dotnet.framew ork.aspnet

is the NG for asp.net

Now regarding your problem I have never used that construction, I do agree
with you that it should be a state problem, but how to find it and correct
it I frankly have no idea.

A possible workaround would be if you use a hidden html control and set the
ID or PK of the datarow in it, then in the postback event handler you know
which was selected.

It would not be perfect but will certainly solve your problem.

What is happening in my opinion is that the inners repeaters are dynamic
controls, hence they needs to be recreated on each postback, how expensive
this is I have no idea really. but you could give it a try.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"DonRex" <Do****@discuss ions.microsoft. com> wrote in message
news:A2******** *************** ***********@mic rosoft.com...
Hello all!

I couldn't find a web application-newsgroup for ASP.NET, so I'm sorry if
this is the wrong forum!

Synopsis:
In my webform I have 3 nested repeaters:

rpWeeks
----- rpTime
---------- rpClasses

I am databinding the first repeater in the !IsPostBack event of the page,
and the data is coming from a Typed Dataset. The next repeater is
DataBound
on its parent's "ItemDataBo und"-event and so on:

private void rpWeeks_ItemDat aBound(object sender, RepeaterItemEve ntArgs e)
{
Repeater rpTime = (Repeater)e.Ite m.FindControl(" rpTime");
rpTime.ItemData Bound += new
RepeaterItemEve ntHandler(rpTim e_ItemDataBound );
//And here is the code to bind the rpTime-repeater, although I've left it
out for simplicity
}

private void rpTime_ItemData Bound(object sender, RepeaterItemEve ntArgs e)
{
//Same thing here.. Getting the repeater and binding
}

All this works perfectly!

However, inside the rpClasses-repeater (the last one) I have a CheckBox
with
an OnCheckedChange d-event and AutoPostBack=Tr ue:

//This event will fire, but RepeaterItem.Da taItem is NULL on PostBack !
public void c_CheckedChange d(object sender, EventArgs e)
{
CheckBox c = (CheckBox)sende r;
RepeaterItem r = (RepeaterItem)c .Parent;
balletDataset.c lassnameRow _cnr = (balletDataset. classnameRow)r. DataItem;
//r.DataItem is NULL on
each
postback and the application will stop!

Response.Write( _cnr.teacher
+ "<br>");
}

I'm pretty sure that this is a state/event-problem, but what can I do to
solve it? I need to have access to the DataItem of the RepeaterItem
because I
have to know what values were selected by the user!

I really hope that someone can help me with this one!

Thanks in advance,

Thomas.


Nov 16 '05 #3
Hi,
Well.. If you've never used this construction before, what construction do
you use then? To me, this is the most "straight-forward" approach I could
think of using nested repeaters, but I may be wrong, and am more than
willing
to learn!


I meant I have never had the need of nesting repeaters, therefore I cannot
tell you (Based on experience) if you need to recreate the nested repeaters
, nevertheless I think you do !.

The hidden approach would solve your problem if all you need to know is a
single value, if the row has a PK in the dataset it should be enough to know
which record was selected.
In general you can post asp.net posts here and most of the time they will be
answered
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Nov 16 '05 #4

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

Similar topics

4
2055
by: John Holmes | last post by:
I'm using data to rename some web controls on a form that uses a repeater contol and so it can have mulitple instances of the same control set. The controls get renamed (thanks to Steven Cheng's help) in a click event of the button that is pushed to enter data. Each time the button is clicked it sends the ID entered by the user to query the database and return information. The renamed controls then include the ID in the name of the...
9
10152
by: Ric | last post by:
im new to asp.net. please help if u can. is it possible to refer to a control(ie lable, placeholder, textbox) that is inside a repeater object from a code behind file? when i place the control object outside of the repeater, i can refer to it from the code behind file. when i place the control object inside the repeater, i get a 'need to instanciate the control object' error. if i declare the control object inside the control behind file,...
2
2274
by: ric carrasquilla | last post by:
first, thx to martin for helping me with my initial post. im a newbie and appreciate the help. if someone can help me with another question, please do. i have a repeater pulling job information from a database. each repeater itemtemplate has with a linkbutton and a row with a label (for now). <asp:repeater ID="EmployeeInfo" OnItemCommand="getActivityList" runat="server">
0
1536
by: Machi | last post by:
let say in parent-child scenerio (Product: Product Category - one product category may has many products), i am using nested repeaters where parent repeater will be used to display info and child repeater will be used to display info, i define the parent and child repeaters once in HTML tag, and create the repeaters for different categories and products repeaters (instances of Repeater) dynamically in Code-Behind using C#, however, when i view...
3
1558
by: louise raisbeck | last post by:
Hi there, I have a brain block on finding a repeater item which matches a field from the row of the datasource. If my datasource has a column called 'somethingid' i want to find the repeateritem which has somethingid=1 (there will only be one) so I have set up an iterator foreach (RepeaterItem item in myrepeater.Items) { //below is what i am trying to do but this doesnt work, not sure of syntax
1
2474
by: Peter Rilling | last post by:
In the Repeater.ItemCreated handler, I am hooking the RepeaterItem.PreRender method. This event fires when the RepeaterItem is being rendered, the problem is that I want access to the DataItem that the RepeaterItem was created from. Well, it appears the DataItem property is null in the RepeaterItem.PreRender event. Why is this. I have read about issues like this relating to Postbacks and ViewState, but I am rebinding each time the...
1
10819
by: jeremystein | last post by:
With nested repeaters, how can I access the outer repeater's DataItem from the inner repeater? Here's a snippet from my aspx: <asp:repeater id="OuterRepeater" runat="server" onItemDataBound="PrepareInner"> <ItemTemplate> <h1> <%# DataBinder.Eval(Container.DataItem, "number") %>
3
4166
by: champ.supernova | last post by:
I have a repeater containing dropdownlists. This subroutine is called when the selected index on one of these dropdownlists is changed... Public Sub cmbProductType_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Dim cmbProductType As DropDownList = CType(sender, DropDownList) Dim objRepeaterItem As RepeaterItem = cmbProductType.Parent
1
4332
PrinsonG
by: PrinsonG | last post by:
My Query is How do I export to excel/csv using Nested Repeaters. My project is web-based and i am using C#.Net. In this i use three repeaters. one displays ID, Name of the user. second displays break details. third displays total time spent.
0
8991
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8830
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9372
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9324
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9247
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8243
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4606
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3313
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 we have to send another system
2
2783
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.