homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

Nested Repeaters - Hiding Child Headers if it contains no data

 8:21 pm on May 28, 2008 (gmt 0)


I have 2 nested repeaters and I am trying to find out how I can stop the headers belonging to the child repeater from showing when there is no data to display in the child repeater.

In the code behind I am building my nested repeaters like this:-
SqlDataAdapter sda = Comments_DataAccess.GetAllComments_SDA(int.Parse(Session["sarID"].ToString()), int.Parse(Session["kqID"].ToString()), "S");
DataSet ds = new DataSet();
sda.Fill(ds, "comments_strength");

SqlDataAdapter sda2 = Actions_DataAccess.GetAllActionsForQuestion_SDA(int.Parse(Session["sarID"].ToString()), int.Parse(Session["kqID"].ToString()));
sda2.Fill(ds, "all_actions");

ds.Relations.Add("sw_id", ds.Tables["comments_strength"].Columns["sw_id"], ds.Tables["all_actions"].Columns["sw_id"], false);

rep_questions_strengths.DataSource = ds.Tables["comments_strength"];

In the aspx page I have the Datasource set on the child Repeater:-
<asp:Repeater ID="rep_questions_strength_actions" DataSource='<%#((DataRowView)Container.DataItem).Row.GetChildRows("sw_id") %>' runat="server">

But at the moment it displays the parent rows and then it displays the child column headers when there are no children to display - I want to stop it from displaying these headers. Can anyone point me in the right direction please?




 11:13 pm on May 28, 2008 (gmt 0)

Would the page render as desired if, given an empty child table, you set the Visible property on the child Repeater to false?


 7:26 am on May 29, 2008 (gmt 0)


This would indeed work but I'm not sure how I can set the child repeaters visible property when I am setting the data for both repeaters using a dataset with a relation?

I think I need to set an event on the repeater but I'm not sure which: OnPreRendering, OnDataBinding, OnItemDataBound, etc.

Any help would be very much appreciated as this is driving me crazy :-)

Thanks for your help so far.



 11:15 am on May 29, 2008 (gmt 0)

Hi Laura,

Handling the PreRender event on the child repeater, and setting Visible (depending on the row count) there sounds like a good idea. I think that DataBinding is raised before data binding occurs, so that wouldn't help, and ItemDataBound is raised per item, so maybe that event could be handled on the parent Repeater.



 11:29 am on May 29, 2008 (gmt 0)

thank you.....I've managed to set the visible property on the repeater tag:-
<%#(((DataRowView)Container.DataItem).Row.GetChildRows("sw_id").Length > 0)%>

thanks again for you''re help

Global Options:
 top home search open messages active posts  

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved