Wednesday, July 27, 2011

Auto number in gridview


<asp:GridView ID="GridView1" runat="server" 
    AutoGenerateColumns="False" 
    DataKeyNames="ProductID,ProductName"
    DataSourceID="SqlDataSource1" 
    BackColor="White" 
    BorderColor="#3366CC" 
    BorderStyle="None" 
    BorderWidth="1px" 
    CellPadding="4" 
    onselectedindexchanged="GridView1_SelectedIndexChanged">
    <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
    <RowStyle BackColor="White" ForeColor="#003399" />
    <Columns>
        <asp:TemplateField> 
            <HeaderTemplate>NO</HeaderTemplate>
            <ItemTemplate><%#Container.DataItemIndex+1%></ItemTemplate>                        
        </asp:TemplateField>  
        <asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" />
        <asp:BoundField DataField="QuantityPerUnit" HeaderText="QuantityPerUnit" SortExpression="QuantityPerUnit" />
        <asp:BoundField DataField="UnitPrice" HeaderText="UnitPrice" SortExpression="UnitPrice" />
        <asp:BoundField DataField="UnitsInStock" HeaderText="UnitsInStock" SortExpression="UnitsInStock" />
        <asp:BoundField DataField="UnitsOnOrder" HeaderText="UnitsOnOrder" SortExpression="UnitsOnOrder" />
    </Columns>
    <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
    <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
    <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
    <AlternatingRowStyle BackColor="#CCFFFF" />
</asp:GridView>

No comments:

Post a Comment