Welcome to WebmasterWorld Guest from 54.198.210.67

Forum Moderators: ocean10000

Message Too Old, No Replies

Nested Repeaters - Hiding Child Headers if it contains no data

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

New User

10+ Year Member

joined:Oct 27, 2004
posts: 9
votes: 0


Hi,

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"];
rep_questions_strengths.DataBind();

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?

Thanks,
Laura

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

Junior Member

10+ Year Member

joined:July 30, 2004
posts:81
votes: 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)

New User

10+ Year Member

joined:Oct 27, 2004
posts: 9
votes: 0


Hi,

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.

Laura

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

Junior Member

10+ Year Member

joined:July 30, 2004
posts:81
votes: 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.

Doug

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

New User

10+ Year Member

joined:Oct 27, 2004
posts: 9
votes: 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

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members