Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello,i'm creating a gridview having columns sr no,test name,dept name.now in this gridview the test name and dept name comes from the sql server. but i also want tht the sr no. column shud automatically get filled like 1,2,3..& do on.. depending on the no. of data items in the datasource..how is tis thing possible?.. please need it urgently..
Posted

Prakash has already given the answer, but I would like to add something.
Check this: auto increment column gridview[^]

I hope you will understand what I meant. :)
 
Share this answer
 
v2
Put this templete inside your gridview:
<asp:TemplateField HeaderText="Sr.no.">                        
     <ItemTemplate>
         <%# Container.DataItemIndex+1 %>
     </ItemTemplate>
</asp:TemplateField>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900