Click here to Skip to main content
15,900,696 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

1.)in my web application, i have two webforms and form.1 contains gridview and it is populated from database, here i am selecting the rows using check box in a gridview and taking those selected rows into next page(form.2) and displaying those selected values in gridview of a form.2.

2.)and here in form.2 i can edit the row values of a gridview and able to save the values,

3.) here i need to auto generate the slno number depends on numbers of rows selected
from form.1 in form.2,

4.)if i repeat the step 1.) then in step 2.) i need to generate the auto increment slno w.r.t previously saved slno .
Posted

1 solution

Try this,

XML
<asp:TemplateField HeaderText="S.No.">
<ItemTemplate>
<asp:Label ID="lblSNo" runat="server" Text="<%# (Container.DataItemIndex)+1 %>"> 
</asp:Label> 
</ItemTemplate>
</asp:TemplateField>
 
Share this answer
 
Comments
Vivek Shankar 11-Jan-12 6:06am    
if the page has 5 items it is generating numbers from 1 to 5, but what i needed is, if i select the some more items for form.2 to should generate the number continuing from 5.
Supriya Srivastav 11-Jan-12 7:46am    
k,then pass that required no as a field and modify the code to add that field in place of 1(As it is now).
Supriya Srivastav 11-Jan-12 7:55am    
Try this,
<asp:Label ID="lblSNo" runat="server"
Text='<%# (Container.DataItemIndex+1)+Convert.ToInt16(Eval("fld")) %>'>

Where fld is the field in which pass no. of rows.

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