Sunday, June 15, 2014

Generate auto id as column id in a repeater in ASP.NET C#

In this example I will show how to add a auto id number as the column no of a repeater.

Lets take a repeater and bind it with a SQLDataSource or by coding. Now add a column to show the index no of the repeater as per your design.

As my design this is the repeater.


<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<div>
   <div><%# Container.ItemIndex + 1 %></div>
   <div>message</div>
</div>
</ItemTemplate>
</asp:Repeater>

Hope you understand which part is creating the index value(column id)..

<%# Container.ItemIndex + 1 %>

Here it is. Place it any where as per your requirement.

Happy coding. :)

0 comments:

Post a Comment

Follow by Email

Popular Posts

Pageviews