Wednesday, April 28, 2010

Auto increment column in gridview ASP.NET

To add an autoincrement column in GridView we can do like this


<asp:GridView ID="gvPurchase" runat="server" AutoGenerateColumns="False" SkinID="sknGvAll">
                        <Columns>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <%# Container.DataItemIndex + 1 %>
                                </ItemTemplate>
                                <HeaderStyle Width="1%" />
                            </asp:TemplateField>
</Columns>
                    </asp:GridView>

No comments:

Popular Posts