473,414 Members | 1,980 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,414 software developers and data experts.

Accessing RepeaterItem.DataItem 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 "ItemDataBound"-event and so on:

private void rpWeeks_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
Repeater rpTime = (Repeater)e.Item.FindControl("rpTime");
rpTime.ItemDataBound += new
RepeaterItemEventHandler(rpTime_ItemDataBound);
//And here is the code to bind the rpTime-repeater, although I've left it
out for simplicity
}

private void rpTime_ItemDataBound(object sender, RepeaterItemEventArgs 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 OnCheckedChanged-event and AutoPostBack=True:

//This event will fire, but RepeaterItem.DataItem is NULL on PostBack !
public void c_CheckedChanged(object sender, EventArgs e)
{
CheckBox c = (CheckBox)sender;
RepeaterItem r = (RepeaterItem)c.Parent;
balletDataset.classnameRow _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 14690
Hi,

microsoft.public.dotnet.framework.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****@discussions.microsoft.com> wrote in message
news:A2**********************************@microsof t.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 "ItemDataBound"-event and so on:

private void rpWeeks_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
Repeater rpTime = (Repeater)e.Item.FindControl("rpTime");
rpTime.ItemDataBound += new
RepeaterItemEventHandler(rpTime_ItemDataBound);
//And here is the code to bind the rpTime-repeater, although I've left it
out for simplicity
}

private void rpTime_ItemDataBound(object sender, RepeaterItemEventArgs 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 OnCheckedChanged-event and AutoPostBack=True:

//This event will fire, but RepeaterItem.DataItem is NULL on PostBack !
public void c_CheckedChanged(object sender, EventArgs e)
{
CheckBox c = (CheckBox)sender;
RepeaterItem r = (RepeaterItem)c.Parent;
balletDataset.classnameRow _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.public.dotnet.framework.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****@discussions.microsoft.com> wrote in message
news:A2**********************************@microsof t.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 "ItemDataBound"-event and so on:

private void rpWeeks_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
Repeater rpTime = (Repeater)e.Item.FindControl("rpTime");
rpTime.ItemDataBound += new
RepeaterItemEventHandler(rpTime_ItemDataBound);
//And here is the code to bind the rpTime-repeater, although I've left it
out for simplicity
}

private void rpTime_ItemDataBound(object sender, RepeaterItemEventArgs 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 OnCheckedChanged-event and AutoPostBack=True:

//This event will fire, but RepeaterItem.DataItem is NULL on PostBack !
public void c_CheckedChanged(object sender, EventArgs e)
{
CheckBox c = (CheckBox)sender;
RepeaterItem r = (RepeaterItem)c.Parent;
balletDataset.classnameRow _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
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...
9
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...
2
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...
0
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...
3
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...
1
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...
1
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"...
3
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...
1
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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
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...
0
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.