在GridView中自动生成列 [英] Auto generate column in a gridview
问题描述
1.)在我的Web应用程序中,我有两个webforms和form.1包含gridview,并且它是从数据库中填充的,这里我使用gridview中的复选框选择行,并将这些选定的行带入下一页(form.2)并在表格的gridview中显示这些选定的值.
2.),然后在form.2中,我可以编辑gridview的行值,并能够保存这些值,
3.)在这里,我需要自动生成slno号,具体取决于所选的行数
从form.1到form.2,
4.)如果我重复步骤1.),然后在步骤2.),我需要生成自动增量slno wrt先前保存的slno.
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 .
推荐答案
尝试一下,
Try this,
<asp:TemplateField HeaderText="S.No.">
<ItemTemplate>
<asp:Label ID="lblSNo" runat="server" Text="<%# (Container.DataItemIndex)+1 %>">
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
这篇关于在GridView中自动生成列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!