第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

獲取Repeter的Item和ItemIndex

標簽:
JavaScript

首先看看效果:

 

 Repeater控件,放在ItemTemplate内的铵钮OnClick之后,获取Repeater的Item,ItemIndex,CommandArgument,CommandName以及绑定的字段值。

准备数据:

View Code

 1 Imports Microsoft.VisualBasic 2 Namespace Insus.NET 3  4     Public Class Catalog 5  6         Private _ID As Integer 7         Private _Name As String 8  9         Public Property ID As Integer10             Get11                 Return _ID12             End Get13             Set(value As Integer)14                 _ID = value15             End Set16         End Property17 18         Public Property Name As String19             Get20                 Return _Name21             End Get22             Set(value As String)23                 _Name = value24             End Set25         End Property26 27     End Class28 End Namespace

 

View Code

 1  Private Function GetData() As List(Of Catalog) 2         Dim cls As New List(Of Catalog) 3  4         Dim cl As Catalog = New Catalog() 5         cl.ID = 1 6         cl.Name = "汽车" 7         cls.Add(cl) 8  9         cl = New Catalog()10         cl.ID = 211         cl.Name = "时尚"12         cls.Add(cl)13 14         cl = New Catalog()15         cl.ID = 316         cl.Name = "科技"17         cls.Add(cl)18 19         cl = New Catalog()20         cl.ID = 521         cl.Name = "文化"22         cls.Add(cl)23 24         cl = New Catalog()25         cl.ID = 626         cl.Name = "公益"27         cls.Add(cl)28         Return cls29     End Function


在.aspx放置Repeater控件:

View Code

 <asp:Repeater ID="RepeaterCatalog" runat="server">                <HeaderTemplate>                    <table border="1" cellpadding="3" cellspacing="0">                        <tr>                            <td>ID                            </td>                            <td>Name                            </td>                            <td>Choose</td>                        </tr>                </HeaderTemplate>                <ItemTemplate>                    <tr>                        <td>                            <asp:Label ID="LabelID" runat="server" Text='<%# Eval("ID")%>'></asp:Label>                        </td>                        <td>                            <asp:Label ID="LabelName" runat="server" Text='<%# Eval("Name")%>'></asp:Label>                        </td>                        <td>                            <asp:Button ID="Button1" runat="server" Text="Select" OnClick="Button1_Click" CommandArgument='<%# Eval("ID")%>' CommandName="Choose" />                        </td>                    </tr>                </ItemTemplate>                <FooterTemplate>                    </table>                </FooterTemplate>            </asp:Repeater>


在.aspx.vb为Repeater控件绑定数据:

View Code

Imports Insus.NETPartial Class Default2    Inherits System.Web.UI.Page    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load        If Not IsPostBack Then            Data_Binding()        End If    End Sub    Private Sub Data_Binding()        Me.RepeaterCatalog.DataSource = GetData()        Me.RepeaterCatalog.DataBind()    End SubEnd Class


接下来,我们写onclick事件,在写事件之前,先在.aspx放一个Label来显示事件结果:

View Code

Process infor:<asp:Label ID="LabelInfo" runat="server" Text=""></asp:Label>

 

View Code

 Protected Sub Button1_Click(sender As Object, e As EventArgs)        Dim btn As Button = DirectCast(sender, Button)        Dim commandArgument As String = btn.CommandArgument        Dim commandName As String = btn.CommandName        Dim item As RepeaterItem = DirectCast(btn.NamingContainer, RepeaterItem)        Dim index As Integer = item.ItemIndex        Dim id As String = DirectCast(item.FindControl("LabelID"), Label).Text        Dim name As String = DirectCast(item.FindControl("LabelName"), Label).Text        Me.LabelInfo.Text = String.Format("Item index: {0}; CommandArgument: {1}; CommandName: {2}; ID: {3}; Name: {4};", index, commandArgument, commandName, id, name)    End Sub


 

點擊查看更多內(nèi)容
TA 點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優(yōu)質(zhì)文章

正在加載中
  • 推薦
  • 評論
  • 收藏
  • 共同學習,寫下你的評論
感謝您的支持,我會繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優(yōu)惠券免費領(lǐng)

立即參與 放棄機會
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號

舉報

0/150
提交
取消