Lorna70
asked on
Using rowspan on RowDataBound
Hi At the following link: http://drcollinsintranet.co.uk.uksite4.yourwebservers.com/freshTest.aspx I have a GridView and I have colour coded some of the rows to show they are grouped by day. This is just a workaround and is not acceptable by the client. I need a way to display the days using Rowspan so if catches are on the same day, the day and date is only displayed once (and vertically centred if possible). I attach my code for the colour coding but I need to adapt it using rowspan (when I tried rowspan before it didn't work and cells disappeared from the GridView. Please can someone help me rewrite this using Rowspan (I have a feeling I need to also use RemoveAt).
freshTest.txt
freshTest.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks but I'm afraid this just pushes cells all over the place and results in:
http://drcollinsintranet.co.uk.uksite4.yourwebservers.com/freshTest2.aspx
http://drcollinsintranet.co.uk.uksite4.yourwebservers.com/freshTest2.aspx
we are setting this for just 1 and 2 column so i dont think it will create any issue can i have your revise code please ?
ASKER
Sorry for the delay - here is my GridView code (codebehind is above). Many thanks.
<asp:GridView ID="gvWeeksCatches" runat="server" AutoGenerateColumns="False " Width="600px"
DataKeyNames="DailyBoatCat chID" DataSourceID="SqlDataSourc e1" ShowFooter="true"
CssClass="GridViewHeader" OnRowDataBound="gvWeeksCat ches_RowDa taBound">
<RowStyle cssclass="GridViewRow" />
<footerstyle HorizontalAlign="Right" />
<Columns>
<asp:BoundField DataField="Catch_Day" HeaderText="Catch Day" ReadOnly="True"
SortExpression="Catch_Day" />
<asp:BoundField DataField="Catch_Date" HeaderText="Date"
SortExpression="Catch_Date " dataformatstring="{0:d MMM yyyy}" />
<asp:BoundField DataField="Common_Name" HeaderText="Product"
SortExpression="Common_Nam e" />
<asp:BoundField DataField="ProductKiloQty" HeaderText="Kilos"
SortExpression="ProductKil oQty" DataFormatString="{0:n}"
ItemStyle-HorizontalAlign= "Right" HeaderStyle-HorizontalAlig n="Right" />
</Columns>
<FooterStyle BackColor="#ffffff" ForeColor="#000000" />
<PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
<SelectedRowStyle BackColor="#000000" Font-Bold="True" ForeColor="#000000" />
<HeaderStyle BackColor="#ffffff" Font-Bold="True" ForeColor="#000000" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnStr %>"
SelectCommand="GetFormData " SelectCommandType="StoredP rocedure">
<SelectParameters>
<asp:QueryStringParameter Name="ID" QueryStringField="ID"
Type="Int32" DefaultValue="28" />
<asp:QueryStringParameter DbType="Date" Name="EndDate"
QueryStringField="EndDate" DefaultValue="27/09/2011" />
</SelectParameters>
</asp:SqlDataSource>
<asp:GridView ID="gvWeeksCatches" runat="server" AutoGenerateColumns="False
DataKeyNames="DailyBoatCat
CssClass="GridViewHeader" OnRowDataBound="gvWeeksCat
<RowStyle cssclass="GridViewRow" />
<footerstyle HorizontalAlign="Right" />
<Columns>
<asp:BoundField DataField="Catch_Day" HeaderText="Catch Day" ReadOnly="True"
SortExpression="Catch_Day"
<asp:BoundField DataField="Catch_Date" HeaderText="Date"
SortExpression="Catch_Date
<asp:BoundField DataField="Common_Name" HeaderText="Product"
SortExpression="Common_Nam
<asp:BoundField DataField="ProductKiloQty"
SortExpression="ProductKil
ItemStyle-HorizontalAlign=
</Columns>
<FooterStyle BackColor="#ffffff" ForeColor="#000000" />
<PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
<SelectedRowStyle BackColor="#000000" Font-Bold="True" ForeColor="#000000" />
<HeaderStyle BackColor="#ffffff" Font-Bold="True" ForeColor="#000000" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnStr %>"
SelectCommand="GetFormData
<SelectParameters>
<asp:QueryStringParameter Name="ID" QueryStringField="ID"
Type="Int32" DefaultValue="28" />
<asp:QueryStringParameter DbType="Date" Name="EndDate"
QueryStringField="EndDate"
</SelectParameters>
</asp:SqlDataSource>
ASKER
This is only a partial solution but there doesn't seem to be away to award less points! Think the solution requires 'RemoveAt' on some cells to work. Nearly there on this so will post another question with what I have so far.
ASKER
http://drcollinsintranet.co.uk.uksite4.yourwebservers.com/freshTest.aspx