如何在ASP:gridview中获得自动递增的列? [英] How to get an autoincremented column in ASP:gridview?

查看:124
本文介绍了如何在ASP:gridview中获得自动递增的列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在创建一个具有sr no,test name,dept name列的gridview.现在在此gridview中,测试名称和部门名称来自sql server.但我也想要sr号.列销会像1,2,3 ..&一样自动填充,具体取决于编号.数据源中的数据项..这怎么可能?..请紧急使用它..

hello,i''m creating a gridview having columns sr no,test name,dept name.now in this gridview the test name and dept name comes from the sql server. but i also want tht the sr no. column shud automatically get filled like 1,2,3..& do on.. depending on the no. of data items in the datasource..how is tis thing possible?.. please need it urgently..

推荐答案

选中此http://www.vbknowledgebase.com/?Id=101&Desc=GridView-Serial-Number-using-RowIndex [ ^ ]


Prakash已经给出了答案,但是我想添加一些内容.
检查以下内容:自动增量列gridview [ ^ ]

希望您能理解我的意思. :)
Prakash has already given the answer, but I would like to add something.
Check this: auto increment column gridview[^]

I hope you will understand what I meant. :)


将此模板放入您的gridview中:
Put this templete inside your gridview:
<asp:TemplateField HeaderText="Sr.no.">                        
     <ItemTemplate>
         <%# Container.DataItemIndex+1 %>
     </ItemTemplate>
</asp:TemplateField>


这篇关于如何在ASP:gridview中获得自动递增的列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆