Welcome to WebmasterWorld Guest from 18.104.22.168
Forum Moderators: ocean10000
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();
SqlDataAdapter sda2 = Actions_DataAccess.GetAllActionsForQuestion_SDA(int.Parse(Session["sarID"].ToString()), int.Parse(Session["kqID"].ToString()));
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?
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.
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.