Saturday, February 8, 2014

bind row index in gridview

 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" >
 <Columns>
 <asp:TemplateField HeaderText="ID" Visible="true">
 <ItemTemplate>
 <%--<asp:Label ID="rowIndex" runat="server" Text='<%# DataBinder.Eval(Container, "RowIndex") %>'></asp:Label>--%>
 
 <asp:Label ID="rowIndex" runat="server" Text='<%# Container.DataItemIndex%>' />
 </ItemTemplate>
 </asp:TemplateField>
 <asp:TemplateField HeaderText="City">
 <ItemTemplate>
 <asp:Label ID="lblName" runat="server" Text='<%#Eval("City") %>'></asp:Label>
 </ItemTemplate>
 </asp:TemplateField>
 </Columns>
 </asp:GridView>


Gv

0 comments:

Post a Comment