Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
my requirement is to get numbers to rows (i.e., 1 for row 1,2 for row 2....)in grid view using c#.net
Posted

1 solution

Add below code to your gridview. This should be your first column in grid:
ASP.NET
<asp:GridView ...>  

     <Columns>   

         <asp:TemplateField>   

           <ItemTemplate>   

                 <%# Container.DataItemIndex + 1 %>.   

             </ItemTemplate>   

             <ItemStyle HorizontalAlign="Right" />   

        </asp:TemplateField>   

         ...   

    </Columns>   

    ...   

 </asp:GridView>    
 
Share this answer
 
Comments
Rahul Rajat Singh 3-Jul-12 6:31am    
good answer. +5. I was also going to suggest the same.
Vani Kulkarni 3-Jul-12 6:36am    
Thanks Rahul! :)

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