I want to display a schedule for a sports league that will show 5 weeks of schedules that come up in the future. Instead of putting 5 datalists or grid controls on one aspx page for each and every week (with codebehind that supports each control tied to
its own datasource and set of ado objects), i'd rather just have one set of ado objects with one sql statement that encompass all 5 weeks of the data, but displaying it in one of the web controls is creating a barrier: how do i assign in the webform control
properties the headers template or the separator template a break when the next week of schedule is to be shown? Do I need a special sql statement in the Compute By or Rollup context to list this report style? Is a datalist or repeater better to use than one
of the grid controls?
If you sort the data properly, you can use some code to have grouping. I use it regularly. It works for Repeater, ListView and GridView. I will explain for GridView. For the others, you can probably do the same trick yourself.
In GridView, make the first column a TemplateField. In the ItemTemplate, put a Panel, followed by what you want in the first Column.
Inside the Panel, put the group header, followed by </td></tr><tr><td>.
Give your page a private member to hold the current week number.
Handle RowDataBound of the GridView. In that, check the RowType.
If it is a Header, set the current week number to a default value that will never occur for real.
If it is a DataRow, use DataBinder.Eval to get the week number from e.Row.DataItem.
Compare it with the current week number. If these are the same, set the Visible of the Panel (use e.Row.FindControl to get it) to false. If they are different, set the Visible of the Panel to True.
If the schedule for each week always has the same number of lines, it is even easier. ListView already supports grouping on a set number of Items.
Superguppie.
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.
This is similar to my problem. I have ordered my list data in a DataTable by week commencing so that I can group my SharePoint list items in a (html) table. I have populated a ListView but as you say this only works for grouping if I have fixed GroupItemCount
which I will not.
in the table below - note the table looked ok in preview & in html editor but when I posted the border is removed and 20;04/12 should be aligned with Task 1, Task 2 and Task 3
W/C date
Title
20/04/12
Task 1
Task 2
Task 3
27/04/12
Task 4
Looks like I will attempt your approach. Is there any help you could give my case / howtos as fairly new to these asp controls
Progress so far
Using my data source
DataTable dataSource = new DataTable();
dataSource.Columns.Add("W/C", typeof(DateTime));
dataSource.Columns.Add("Title");
I can produce the default 2 colum table with appropriate header columns by simply placing the following markup on the page (in a Web Part) and binding the datasource. looks ok
I have order the data in my DataTable by the DateTime fields: "W/C ASC"
Now I want to group my task actions horizonatally by the W/C (week commencing date), based on your intructions I have got this far
<asp:GridView ID="DataGridView" runat="server" OnRowDataBound="DataGridView_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="W/C">
<ItemTemplate>
<asp:Panel ID="TimelineGroupPanel" runat="server">
How do I put in the group header....
</asp:Panel>
<%#Eval("W/C")%>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Chumley Walr...
Member
621 Points
234 Posts
Datalist, repeater, or grid ? Need to display 5 sets of data...
Mar 01, 2012 04:27 AM|LINK
I want to display a schedule for a sports league that will show 5 weeks of schedules that come up in the future. Instead of putting 5 datalists or grid controls on one aspx page for each and every week (with codebehind that supports each control tied to its own datasource and set of ado objects), i'd rather just have one set of ado objects with one sql statement that encompass all 5 weeks of the data, but displaying it in one of the web controls is creating a barrier: how do i assign in the webform control properties the headers template or the separator template a break when the next week of schedule is to be shown? Do I need a special sql statement in the Compute By or Rollup context to list this report style? Is a datalist or repeater better to use than one of the grid controls?
???
TIA
chumley
mameenkhn
Contributor
2026 Points
391 Posts
Re: Datalist, repeater, or grid ? Need to display 5 sets of data...
Mar 01, 2012 04:40 AM|LINK
use nested repeater.... in first repeater weeks and in nested repeater schedule
--------------------------------------------------
Muhammad Amin
محمد امين
superguppie
All-Star
48225 Points
8679 Posts
Re: Datalist, repeater, or grid ? Need to display 5 sets of data...
Mar 01, 2012 01:12 PM|LINK
If you sort the data properly, you can use some code to have grouping. I use it regularly. It works for Repeater, ListView and GridView. I will explain for GridView. For the others, you can probably do the same trick yourself.
In GridView, make the first column a TemplateField. In the ItemTemplate, put a Panel, followed by what you want in the first Column.
Inside the Panel, put the group header, followed by </td></tr><tr><td>.
Give your page a private member to hold the current week number.
Handle RowDataBound of the GridView. In that, check the RowType.
If it is a Header, set the current week number to a default value that will never occur for real.
If it is a DataRow, use DataBinder.Eval to get the week number from e.Row.DataItem.
Compare it with the current week number. If these are the same, set the Visible of the Panel (use e.Row.FindControl to get it) to false. If they are different, set the Visible of the Panel to True.
If the schedule for each week always has the same number of lines, it is even easier. ListView already supports grouping on a set number of Items.
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.
westerdaled2
Member
2 Points
4 Posts
Re: Datalist, repeater, or grid ? Need to display 5 sets of data...
May 01, 2012 10:29 AM|LINK
Hi (supergroupie)
This is similar to my problem. I have ordered my list data in a DataTable by week commencing so that I can group my SharePoint list items in a (html) table. I have populated a ListView but as you say this only works for grouping if I have fixed GroupItemCount which I will not.
in the table below - note the table looked ok in preview & in html editor but when I posted the border is removed and 20;04/12 should be aligned with Task 1, Task 2 and Task 3
W/C date
Title
20/04/12
Task 1
Task 2
Task 3
27/04/12
Task 4
Looks like I will attempt your approach. Is there any help you could give my case / howtos as fairly new to these asp controls
Progress so far
Using my data source
DataTable dataSource = new DataTable(); dataSource.Columns.Add("W/C", typeof(DateTime)); dataSource.Columns.Add("Title");I can produce the default 2 colum table with appropriate header columns by simply placing the following markup on the page (in a Web Part) and binding the datasource. looks ok
I have order the data in my DataTable by the DateTime fields: "W/C ASC"
Now I want to group my task actions horizonatally by the W/C (week commencing date), based on your intructions I have got this far
<asp:GridView ID="DataGridView" runat="server" OnRowDataBound="DataGridView_RowDataBound"> <Columns> <asp:TemplateField HeaderText="W/C"> <ItemTemplate> <asp:Panel ID="TimelineGroupPanel" runat="server"> How do I put in the group header.... </asp:Panel> <%#Eval("W/C")%> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>