13 September 2013

How to add Serial Number as the First Column in a GridView

 <asp:GridView ID="gv1" runat="server" AutoGenerateColumns="false">
                            <Columns>
                                <asp:TemplateField HeaderText="S No">
                                    <ItemTemplate>
                                        <%# Container.DataItemIndex + 1 %>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Name">
                                    <ItemTemplate>
                                        <%# Eval("name") %>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
   </asp:GridView>

No comments:

Post a Comment