Please see the below link.
Notice the far left column does not have text in the header and also notice that the ranking starts with number "0". Rather than "1".
If anyone can see my code and see where I went wrong I would be greatly appreciated.
I would like the header to have the work "Rank" in the fist row of the first column.
http://visualboxscore.com/cfb/team_s...l_offense.aspx
Code:<%@ Page Language="C#" MasterPageFile="~/AppMaster.master" Title="visualboxscore - CFB Total Offense" %> <asp:Content ID="Content1" runat="server" ContentPlaceHolderID="mainCopy"> <script runat="server"> protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { int row = e.Row.RowIndex + (GridView1.PageSize * GridView1.PageIndex); ((Label)e.Row.FindControl("Rank")).Text = row.ToString(); } } </script> <div class="container" style="height: 80%"> <br> <asp:GridView ID="GridView1" AllowSorting="true" runat="server" DataSourceID="SqlDataSource1" OnRowDataBound="GridView1_RowDataBound" SkinID="booksSkin" AutoGenerateColumns="False" HorizontalAlign="Left"> <Columns> <asp:TemplateField> <itemtemplate> <asp:Label ID="Rank" runat="server" Text="Rank"></asp:Label> </itemtemplate> </asp:TemplateField> <asp:BoundField HeaderText="Team" DataField="team" ItemStyle-HorizontalAlign="Center"/> <asp:BoundField HeaderText="Plays/Gm" DataField="total_plays" ItemStyle-HorizontalAlign="Center" SortExpression="total_plays" /> <asp:BoundField HeaderText="Total Yards" DataField="total_yds" ItemStyle-HorizontalAlign="Center" SortExpression="total_yds" /> <asp:BoundField HeaderText="YPP" DataField="yds_per_play" ItemStyle-HorizontalAlign="Center" SortExpression="yds_per_play" /> </Columns> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" SelectCommand="SELECT [team], [total_plays], [total_yds], [yds_per_play], [punt_no], [total_first_downs] FROM [team_avg] ORDER BY [total_yds] DESC" ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>" /> </div> </asp:Content>




Reply With Quote