婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識(shí)庫 > gridview行索引獲取方法及實(shí)現(xiàn)代碼

gridview行索引獲取方法及實(shí)現(xiàn)代碼

熱門標(biāo)簽:預(yù)測式外呼系統(tǒng)使用說明 蘋果手機(jī)凱立德地圖標(biāo)注 玉林市機(jī)器人外呼系統(tǒng)哪家好 電話機(jī)器人軟件銷售工作 合肥電銷外呼系統(tǒng)哪家公司做的好 南陽外呼系統(tǒng)定制化 申請(qǐng)400電話手續(xù) 百度ai地圖標(biāo)注 同安公安400電話怎么申請(qǐng)流程
Insus.NET為了演示這個(gè)例子,首先準(zhǔn)好數(shù)據(jù),創(chuàng)建一個(gè)類別
Cosmetic.vb
復(fù)制代碼 代碼如下:

Imports Microsoft.VisualBasic
Namespace Insus.NET
Public Class Cosmetic
Private _ID As Integer
Private _Type As String
Private _Name As String
Private _Weight As Decimal
Private _UM As String
Public Property ID As Integer
Get
Return _ID
End Get
Set(value As Integer)
_ID = value
End Set
End Property
Public Property Type As String
Get
Return _Type
End Get
Set(value As String)
_Type = value
End Set
End Property
Public Property Name As String
Get
Return _Name
End Get
Set(value As String)
_Name = value
End Set
End Property
Public Property Weight As Decimal
Get
Return _Weight
End Get
Set(value As Decimal)
_Weight = value
End Set
End Property
Public Property UM As String
Get
Return _UM
End Get
Set(value As String)
_UM = value
End Set
End Property
Public Sub New()
End Sub
Public Sub New(id As Integer, type As String, name As String, weight As Decimal, um As String)
Me._ID = id
Me._Type = type
Me._Name = name
Me._Weight = weight
Me._UM = um
End Sub
End Class
End Namespace

上面創(chuàng)建好的只是一對(duì)象,得需用數(shù)據(jù)填充,讓它有血有肉有靈魂。
復(fù)制代碼 代碼如下:

Private Function GetData() As List(Of Cosmetic)
Dim o As New List(Of Cosmetic)
Dim c As New Cosmetic(1, "滋潤霜", "玉蘭油", 50, "g")
o.Add(c)
Dim c1 As New Cosmetic(2, "滋潤霜", "雅詩蘭黛", 100, "g")
o.Add(c1)
Dim c2 As New Cosmetic(3, "滋潤霜", " 蘭蔻", 80, "g")
o.Add(c2)
Dim c3 As New Cosmetic(4, "滋潤霜", "歐萊雅", 60, "g")
o.Add(c3)
Dim c4 As New Cosmetic(5, "滋潤霜", "芭比波朗", 120, "g")
o.Add(c4)
Return o
End Function

在aspx網(wǎng)頁上放一個(gè)Gridview控件
復(fù)制代碼 代碼如下:

asp:GridView ID="GridViewCosmetic" runat="server" Width="300" AutoGenerateColumns="false">
Columns>
asp:TemplateField>
HeaderTemplate>
ID
/HeaderTemplate>
ItemTemplate>
%# Eval("ID")%>
/ItemTemplate>
/asp:TemplateField>
asp:TemplateField>
HeaderTemplate>
Type
/HeaderTemplate>
ItemTemplate>
%# Eval("Type")%>
/ItemTemplate>
/asp:TemplateField>
asp:TemplateField>
HeaderTemplate>
Name
/HeaderTemplate>
ItemTemplate>
%# Eval("Name")%>
/ItemTemplate>
/asp:TemplateField>
asp:TemplateField>
ItemStyle HorizontalAlign="Right" />
HeaderTemplate>
Weight
/HeaderTemplate>
ItemTemplate>
%# Eval("Weight")%>
/ItemTemplate>
/asp:TemplateField>
asp:TemplateField>
HeaderTemplate>
UM
/HeaderTemplate>
ItemTemplate>
%# Eval("UM") %>
/ItemTemplate>
/asp:TemplateField>
/Columns>
/asp:GridView>

當(dāng)然得對(duì)這個(gè)控件,進(jìn)行數(shù)據(jù)綁定,引用命名空間Imports Insus.NET
復(fù)制代碼 代碼如下:

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.GridViewCosmetic.DataSource = GetData()
Me.GridViewCosmetic.DataBind()
End Sub

接下來,我們開始演示,在GridView控件最后一列,添加一列,選擇列:
復(fù)制代碼 代碼如下:

asp:TemplateField>
ItemTemplate>
asp:LinkButton ID="LinkButton1" runat="server" Text="選擇" OnClientClick="return GetSelectedRow(this)" />
/ItemTemplate>
/asp:TemplateField>

上面html代碼中,有一個(gè)OnClientClick="return GetSelectedRow(this)" 客戶端事件。
復(fù)制代碼 代碼如下:

script type="text/javascript">
function GetSelectedRow(obj) {
var row = obj.parentNode.parentNode;
var rowIndex = row.rowIndex - 1;
alert("你選擇的行索引是:" + rowIndex);
return false;
}
/script>

動(dòng)畫演示
您可能感興趣的文章:
  • ASP.NET GridView中文本內(nèi)容無法換行(自動(dòng)換行/正常換行)
  • ASP.NET GridView 實(shí)現(xiàn)課程表顯示(動(dòng)態(tài)合并單元格)實(shí)現(xiàn)步驟
  • GridView選擇記錄同時(shí)confirm用戶確認(rèn)刪除
  • ASP.NET GridView控件在列上格式化時(shí)間及DataFormatString使用
  • Asp.net簡單代碼設(shè)置GridView自適應(yīng)列寬不變形實(shí)現(xiàn)思路與代碼
  • GridView多層嵌套和折疊與展開(修改適合自己使用)
  • GridView分頁代碼簡單萬能實(shí)用
  • C#與SQL連接:GridView控件對(duì)數(shù)據(jù)庫的操作

標(biāo)簽:揚(yáng)州 南京 臺(tái)州 海南 南昌 南京 淄博 嘉興

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《gridview行索引獲取方法及實(shí)現(xiàn)代碼》,本文關(guān)鍵詞  gridview,行,索引,獲取,方法,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《gridview行索引獲取方法及實(shí)現(xiàn)代碼》相關(guān)的同類信息!
  • 本頁收集關(guān)于gridview行索引獲取方法及實(shí)現(xiàn)代碼的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 馆陶县| 琼结县| 敦化市| 沙坪坝区| 大方县| 吉林省| 乐清市| 精河县| 麻城市| 嘉祥县| 大城县| 江山市| 十堰市| 高清| 乐陵市| 临武县| 米林县| 刚察县| 桦南县| 瑞金市| 新建县| 罗江县| 卢氏县| 通辽市| 瑞丽市| 彭泽县| 康平县| 沾化县| 建平县| 乌拉特前旗| 永和县| 肥城市| 丹寨县| 新建县| 区。| 三江| 白银市| 台前县| 惠东县| 曲水县| 镇沅|