GridView控件如何顯示序號(hào)
在ASP.NET 中,如果想 GridView 列表中顯示序列號(hào),不需要自己編寫獲取序號(hào)的方法,通過Container.DataItemIndex 屬性加 1 就可以實(shí)現(xiàn)了,綁定在列表中就 OK 了!
實(shí)例代碼:
<asp:GridView ID="gvList" runat="server" Width="100%"> <Columns> <asp:TemplateField HeaderText="序號(hào)" HeaderStyle-Width="10%"> <ItemTemplate> <%# (Container.DataItemIndex + 1).ToString()%> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="地市"> <ItemTemplate> <%# Eval("City").ToString()%> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="企業(yè)名稱"> <ItemTemplate> <%# Eval("Com_Name")%> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>
展示效果:
是不是實(shí)現(xiàn)方法很簡(jiǎn)單,如果項(xiàng)目中需要實(shí)現(xiàn)GridView列表中顯示序列號(hào),就按照上面的做法動(dòng)手實(shí)現(xiàn)吧!
- GridView自動(dòng)增加序號(hào)(三種實(shí)現(xiàn)方式)
- C#處理datagridview虛擬模式的方法
- C#中datagridview的EditingControlShowing事件用法實(shí)例
- C#中GridView動(dòng)態(tài)添加列的實(shí)現(xiàn)方法
- C#實(shí)現(xiàn)DataGridView控件行列互換的方法
- C#實(shí)現(xiàn)綁定DataGridView與TextBox之間關(guān)聯(lián)的方法
- C#中DataGridView常用操作實(shí)例小結(jié)
- C#實(shí)現(xiàn)3步手動(dòng)建DataGridView的方法
- asp.net中GridView數(shù)據(jù)鼠標(biāo)移入顯示提示信息
- C#中DataGridView動(dòng)態(tài)添加行及添加列的方法
- GridView使用學(xué)習(xí)總結(jié)
- 如何用jQuery實(shí)現(xiàn)ASP.NET GridView折疊伸展效果
- ASP.NET GridView中加入RadioButton不能單選的解決方案
- DataGridView展開與收縮功能實(shí)現(xiàn)
相關(guān)文章
asp.net 關(guān)于==?:和if()else()條件判斷等效例子
關(guān)于==?:和if()else() 等效例子2010-03-03asp.net后臺(tái)如何動(dòng)態(tài)添加JS文件和css文件的引用
動(dòng)態(tài)添加JS文件和css文件的引用在asp.net后臺(tái)如何實(shí)現(xiàn)呢?首先添加命名空間 using System.Web.UI.HtmlControls,之后按照下面的步驟操作即可2014-09-09Entity Framework使用Code First模式管理數(shù)據(jù)庫
本文詳細(xì)講解了Entity Framework使用Code First模式管理數(shù)據(jù)庫的方法,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-03-03.NET RulesEngine(規(guī)則引擎)的使用詳解
這篇文章主要介紹了.NET RulesEngine(規(guī)則引擎)的使用詳解,幫助大家更好的理解和學(xué)習(xí)使用.net技術(shù),感興趣的朋友可以了解下2021-05-05