468,110 Members | 1,583 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,110 developers. It's quick & easy.

Nested repeater controls show/hide?

Hi All,

Posted after extensive searching!

I have a nested repeater control as follows: (Simplified ;-))

<table>
<asp:repeater id=parent onItemDataBound=createChild>
<tr><td>Level 1</td></tr>
<asp:repeater id=child>
<tr id=childrow><td>Level 2</td></tr>
</asp:repeater>
</asp:repeater>
</table>

They are both created from a SQL query. I would simply like to not
display the child if the parent meets a condition. I would therefore
like to add a style="display: none;" attribute to the row 'childrow'.

How can I access the child of the parent in the onItemDataBound event,
which is when it gets created? I can access anything outside the child
repeater but not inside it.

(As a side issues all ID's are dynamically created at databind time
for use with Javascript etc.)

Help would be much appreciated!

Thanks
John Sourcrer
Nov 19 '05 #1
3 4141
You say you can't access anthing inside the child repeater, but can you
access the child repeater itself ala e.Item.FindControl("child") if so,
why not just set it's visiblility to false, not bind it and voila?

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"sorCrer" <ju**@spirit.co.za> wrote in message
news:dc*************************@posting.google.co m...
Hi All,

Posted after extensive searching!

I have a nested repeater control as follows: (Simplified ;-))

<table>
<asp:repeater id=parent onItemDataBound=createChild>
<tr><td>Level 1</td></tr>
<asp:repeater id=child>
<tr id=childrow><td>Level 2</td></tr>
</asp:repeater>
</asp:repeater>
</table>

They are both created from a SQL query. I would simply like to not
display the child if the parent meets a condition. I would therefore
like to add a style="display: none;" attribute to the row 'childrow'.

How can I access the child of the parent in the onItemDataBound event,
which is when it gets created? I can access anything outside the child
repeater but not inside it.

(As a side issues all ID's are dynamically created at databind time
for use with Javascript etc.)

Help would be much appreciated!

Thanks
John Sourcrer

Nov 19 '05 #2
Hi Karl,

Thanks for your post but this I can do! What I am trying to do is bind
the data, then add a style attribute that sets its display property to
false. I need to do this because I want to dynamically display the
children when a user clicks on a +/- icon. Like any standard tree type
menu.

Any ideas?

Interesting articles on your site BTW.

Regards
John

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:<ed**************@TK2MSFTNGP09.phx.gbl>...
You say you can't access anthing inside the child repeater, but can you
access the child repeater itself ala e.Item.FindControl("child") if so,
why not just set it's visiblility to false, not bind it and voila?

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"sorCrer" <ju**@spirit.co.za> wrote in message
news:dc*************************@posting.google.co m...
Hi All,

Posted after extensive searching!

I have a nested repeater control as follows: (Simplified ;-))

<table>
<asp:repeater id=parent onItemDataBound=createChild>
<tr><td>Level 1</td></tr>
<asp:repeater id=child>
<tr id=childrow><td>Level 2</td></tr>
</asp:repeater>
</asp:repeater>
</table>

They are both created from a SQL query. I would simply like to not
display the child if the parent meets a condition. I would therefore
like to add a style="display: none;" attribute to the row 'childrow'.

How can I access the child of the parent in the onItemDataBound event,
which is when it gets created? I can access anything outside the child
repeater but not inside it.

(As a side issues all ID's are dynamically created at databind time
for use with Javascript etc.)

Help would be much appreciated!

Thanks
John Sourcrer

Nov 19 '05 #3
John:
You could simply use
http://www.denisbauer.com/ASPNETCont...ierarGrid.aspx

You'll likely have some difficulty doing this with a repeater, namely
because I assume you have something like:

<HeaderTemplate>
<table border="0" ...>
</headertemplate>
<itemTempalte>...</ItemTEmplate>
<footerTempalte</table></footerTemplate>

and you need to programatically set the visibility style of the <Table>
which you won't be able to find using FindControl since it isn't a server
control...you can't simply add a runat=server (I think) because it doesn't
think it has a closing </table> tag.

What you could do is place the table control outside the child repeater:
<ItemTemplate>
<td><%# DataBinder.Eval(Container.DataItem ,"Name")%>
<table id="x" runat="server">
<asp:Repeater ID="inner" DataSource='...' Runat="server">
<ItemTemplate>
<tr><td><%# DataBinder.Eval(Container.DataItem,
"Amount")%></td></td>
</ItemTemplate>
</asp:Repeater>
</table>>
</td>
</ItemTemplate>

which you could then access it from the outer repeater...or simply use:

<table style='visibility:<%# GetVisibility(Container.DataItem) %>'> or
something...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/index.aspx - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"sorCrer" <ju**@spirit.co.za> wrote in message
news:dc**************************@posting.google.c om...
Hi Karl,

Thanks for your post but this I can do! What I am trying to do is bind
the data, then add a style attribute that sets its display property to
false. I need to do this because I want to dynamically display the
children when a user clicks on a +/- icon. Like any standard tree type
menu.

Any ideas?

Interesting articles on your site BTW.

Regards
John

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>

wrote in message news:<ed**************@TK2MSFTNGP09.phx.gbl>...
You say you can't access anthing inside the child repeater, but can you
access the child repeater itself ala e.Item.FindControl("child") if so, why not just set it's visiblility to false, not bind it and voila?

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"sorCrer" <ju**@spirit.co.za> wrote in message
news:dc*************************@posting.google.co m...
Hi All,

Posted after extensive searching!

I have a nested repeater control as follows: (Simplified ;-))

<table>
<asp:repeater id=parent onItemDataBound=createChild>
<tr><td>Level 1</td></tr>
<asp:repeater id=child>
<tr id=childrow><td>Level 2</td></tr>
</asp:repeater>
</asp:repeater>
</table>

They are both created from a SQL query. I would simply like to not
display the child if the parent meets a condition. I would therefore
like to add a style="display: none;" attribute to the row 'childrow'.

How can I access the child of the parent in the onItemDataBound event,
which is when it gets created? I can access anything outside the child
repeater but not inside it.

(As a side issues all ID's are dynamically created at databind time
for use with Javascript etc.)

Help would be much appreciated!

Thanks
John Sourcrer

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by mark | last post: by
12 posts views Thread by Jerad Rose | last post: by
reply views Thread by Ed Allan | last post: by
reply views Thread by Ed Allan | last post: by
reply views Thread by Maziar Aflatoun | last post: by
2 posts views Thread by Matt Jensen | last post: by
2 posts views Thread by mark | last post: by
reply views Thread by bdtmike | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.