您的位置:首页 > 其它

GridView简单创建序号列

2009-01-02 15:35 204 查看
在gridview中添加模板列,并在模板列中放入lable使用Container.DataItemIndex绑定text属性,需要注意,DataItemIndex是从0开始。如下代码:
<asp:TemplateField HeaderText="序号">
<ItemTemplate>
<asp:Literal ID="Literal2" runat="server" Text='<%# Container.DataItemIndex + 1 %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: