Display row# in gridview

19. February 2010

  How to display row#  in gridview, DataGrid,Repeater or DataListGridView is one of most widely used controls and we can do lots of things with the control.

 In ASP.Net 2.0, Datagrid is replaced by GridView control while Datagrid control is still supported. There are large numbers of tasks that can be done through grid view control.

<%@ Page Language="C#"%>
<script runat="server">

protectedvoid Page_Load(object sender, EventArgs e)
{
gridView1.DataSource =newstring[] { "Aamir Hasan", "www.studentacad.com", "aspxtutorial.com" };
gridView1.DataBind();

}
</script>
<html>
<head runat="server">
<title>GridView Row number's</title>
</head>
<body>
<form id="form2" runat="server">
<div>
<asp:GridView runat="server" ID="gridView1">
<Columns>
<asp:TemplateField HeaderText="#">
<ItemTemplate>
<%# Container.DataItemIndex + 1 %>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>

 Links

GridViewRow

 


Author: Aamir Hasan     औथोर: आमिर हसन       أثر أمير حسن .

ALL, asp.net ,


Comments

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading





User Name: Guest

Your Ip: 38.107.191.91
Time: