asp.net獲取ListView與gridview中當(dāng)前行的行號
本文實(shí)例講述了asp.net獲取ListView與gridview中當(dāng)前行的行號。分享給大家供大家參考,具體如下:
aspx中,在gridview/ListView中,有一模板列,就叫l(wèi)inkbutton,想單擊它時,獲取它所在行的索引值
ListView中:
第一種:
<ItemTemplate> <tr> <td> <asp:LinkButton runat="server" ID="btnSelected" Text='<%# (Container.DisplayIndex+1).ToString() %>' ></asp:LinkButton> </td> </tr> </ItemTemplate>
第二種:
<ItemTemplate> <li> <asp:LinkButton ID="btnDelete" runat="server" CommandName="Delete" Text="<%# Container.DataItem %>"></asp:LinkButton> </li> </ItemTemplate>
gridview中
第一種:
<itemtemplate> <asp:LinkButton ID="LinkButton1" runat="server" </itemtemplate>
protected void LinkButton1_Click(object sender, EventArgs e) { //行號 int row = ((GridViewRow)((LinkButton)sender).NamingContainer).RowIndex; }
第二種:
<asp:GridView ID="gvTest" runat="server"> <Columns> <asp:TemplateField> <ItemTemplate> DisplayIndex : <%# Container.DisplayIndex %> || DataItemIndex : <%# Container.DataItemIndex %><br /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>
希望本文所述對大家asp.net程序設(shè)計有所幫助。
- Android 中ScrollView嵌套GridView,ListView的實(shí)例
- 關(guān)于Android中ListView嵌套GridView的問題
- Android之ScrollView嵌套ListView和GridView沖突的解決方法
- ListView嵌套GridView使用詳解及注意事項(xiàng)
- 淺談RecyclerView(完美替代ListView,GridView)
- Android開發(fā)之ListView、GridView 詳解及示例代碼
- Android RecyclerView詳解之實(shí)現(xiàn) ListView GridView瀑布流效果
- 解決EditText、ListView以及GridView同時使用,輸入法自動跳出來的方法
- android ListView和GridView拖拽移位實(shí)現(xiàn)代碼
- Android仿貼吧內(nèi)容下的簡單ListView嵌套GridView
相關(guān)文章
ASP.NET MVC重寫RazorViewEngine實(shí)現(xiàn)多主題切換
這篇文章主要為大家詳細(xì)介紹了ASP.NET MVC重寫RazorViewEngine實(shí)現(xiàn)多主題切換,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-06-06SqlDataReader指定轉(zhuǎn)換無效的解決方法
這篇文章主要為大家詳細(xì)介紹了SqlDataReader指定轉(zhuǎn)換無效的解決方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-06-06C# 文件保存到數(shù)據(jù)庫中或者從數(shù)據(jù)庫中讀取文件
在編程中我們常常會遇到“將文件保存到數(shù)據(jù)庫中”這樣一個問題,雖然這已不是什么高難度的問題,但對于一些剛剛開始編程的朋友來說可能是有一點(diǎn)困難。2009-03-03在asp.net下實(shí)現(xiàn)Option條目中填充前導(dǎo)空格的方法
在asp.net下實(shí)現(xiàn)Option條目中填充前導(dǎo)空格的方法...2007-03-03ASP.NET 使用application與session對象寫的簡單聊天室程序
寫了快一年的asp.net,application對象還真沒怎么用過。看了看書,根據(jù)這兩個對象的特性寫了一個簡單的聊天室程序。真的是非常的簡陋2014-07-07asp.net使用npoi讀取excel模板并導(dǎo)出下載詳解
這篇文章主要介紹了asp.net使用npoi讀取excel模板并導(dǎo)出下載的示例,大家參考使用吧2014-01-01asp.net中在用ajax格式傳遞數(shù)據(jù)到aspx頁面時出現(xiàn)亂碼
asp.net中在用ajax格式傳遞數(shù)據(jù)到aspx頁面時有時會出現(xiàn)亂碼,很是疑惑,不要走開接下來介紹解決方法,感興趣的朋友可以了解下2013-01-01ASP.NET也像WinForm程序一樣運(yùn)行的實(shí)現(xiàn)方法
我們今天要談到的是讓ASP.NET的程序也像WinForm一樣的運(yùn)行,這樣就不需要安裝IIS或者Visual Studio這樣的特定環(huán)境了2012-01-01