Hey everyone!
Very new to C# although I have alot of older coding experience. Not much object orientated programming though. Anyways, I have a .net program I'm working on, basically to work on my skills although it will prove to be useful. I am keeping track of my work schedule. Currently, I am populating a datagridview from a sql 2008 express db. My columns are: date worked, hours, paid, and paidon. What I want to do is add an empty row whenever the date corresponds to a date that is "Monday". My goal is to line break every week. So that each work week (Mon-Sun) is seperated by a blank row. I would rather not actually have this blank row in the database. I would like the gridview to do this on the fly. Here is my gridview code in my default.aspx file:
01.<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="key"
02. DataSourceID="SqlDataSource1"
03. EmptyDataText="There are no data records to display." CellPadding="4"
04. ForeColor="#333333" GridLines="None" Height="99px" Width="887px" OnLoad="GridView1_Seperate">
05. <AlternatingRowStyle BackColor="White" />
06. <Columns>
07. <asp:BoundField DataField="date" HeaderText="Date Worked:"
08. SortExpression="date" >
09. <HeaderStyle HorizontalAlign="Left" />
10. </asp:BoundField>
11. <asp:BoundField DataField="hours" HeaderText="# of Hours Worked:"
12. SortExpression="hours" >
13. <HeaderStyle HorizontalAlign="Left" />
14. </asp:BoundField>
15. <asp:BoundField DataField="paid" HeaderText="Paid?" SortExpression="paid" >
16. <HeaderStyle HorizontalAlign="Left" />
17. </asp:BoundField>
18. <asp:BoundField DataField="paidon" HeaderText="If Paid, Paid Date?"
19. SortExpression="paidon" >
20. <HeaderStyle HorizontalAlign="Left" />
21. </asp:BoundField>
22. </Columns>
23. <EditRowStyle BackColor="#2461BF" />
24. <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
25. <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
26. <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
27. <RowStyle BackColor="#EFF3FB" />
28. <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
29. <SortedAscendingCellStyle BackColor="#F5F7FB" />
30. <SortedAscendingHeaderStyle BackColor="#6D95E1" />
31. <SortedDescendingCellStyle BackColor="#E9EBEF" />
32. <SortedDescendingHeaderStyle BackColor="#4870BE" />
33. </asp:GridView>
34. <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:OlympicConnectionString1 %>"
35. DeleteCommand="DELETE FROM [SchedulePay] WHERE [key] = @key" InsertCommand="INSERT INTO [SchedulePay] ([date], [hours], [paid], [paidon]) VALUES (@date, @hours, @paid, @paidon)"
36. ProviderName="<%$ ConnectionStrings:OlympicConnectionString1.ProviderName %>"
37. SelectCommand="SELECT [key], [date], [hours], [paid], [paidon] FROM [SchedulePay] ORDER BY [date] DESC"
38.
39. UpdateCommand="UPDATE [SchedulePay] SET [date] = @date, [hours] = @hours, [paid] = @paid, [paidon] = @paidon WHERE [key] = @key">
40. <DeleteParameters>
41. <asp:Parameter Name="key" Type="Int32" />
42. </DeleteParameters>
43. <InsertParameters>
44. <asp:Parameter DbType="Date" Name="date" />
45. <asp:Parameter Name="hours" Type="Double" />
46. <asp:Parameter Name="paid" Type="Int32" />
47. <asp:Parameter DbType="Date" Name="paidon" />
48. </InsertParameters>
49. <UpdateParameters>
50. <asp:Parameter DbType="Date" Name="date" />
51. <asp:Parameter Name="hours" Type="Double" />
52. <asp:Parameter Name="paid" Type="Int32" />
53. <asp:Parameter DbType="Date" Name="paidon" />
54. <asp:Parameter Name="key" Type="Int32" />
55. </UpdateParameters>
56. </asp:SqlDataSource>