Two simple methods
1. <itemtemplate>
<Tr> <TD>
<% # Container. itemindex + 1%>
</TD> </tr>
</Itemtemplate>
2. <itemtemplate>
<Tr> <TD>
<% # This. rpresult. Items. Count + 1%>
</TD> </tr>
</Itemtemplate>
Two other methods:
Add <label id = "DD"> </label> in <form> </form>
<Body nload = "show ()">
<Script. Language = "jscript">
Function show ()
{
VaR bj = Document. All. Tags ("label ");
For (I = 0; I <obj. length; I ++)
{
Document. All ["DD"] [I]. innerhtml = I + 1;
}
}
</SCRIPT>
4. Background implementation
Background implementation:
Add <asp: Label id = "label1" runat = "server"> </ASP: Label> in. aspx
Add in. CS
** Void initializecomponent ()
{
This. repeater1.itemdatabound + = new system. Web. UI. webcontrols. repeateritemeventhandler(This. repeaterincluitemdatabound );
This. Load + = new system. eventhandler (this. page_load );
}
** Void repeaterincluitemdatabound (Object source, system. Web. UI. webcontrols. repeateritemeventargs E)
{
If (E. Item. itemtype = listitemtype. Item | E. Item. itemtype = listitemtype. alternatingitem)
{
(Label) E. Item. findcontrol ("label1"). Text = convert. tostring (E. Item. itemindex + 1 );
}
}