Imports System.Data
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles Me.Load
If Not IsPostBack Then
Dim dt As New DataTable
dt.Columns.Add("CustomerID", GetType(String))
dt.Columns.Add("CustomerNm", GetType(String))
dt.Columns.Add("TEL", GetType(String))
Dim row As DataRow
For i As Integer = 1 To 10
row = dt.NewRow
row("CustomerID") = i.ToString
row("CustomerNm") = "会社名" & i.ToString
row("TEL") = i & i & i & "-" & i & i & i & i & "-" & i & i & i & i
dt.Rows.Add(row)
Next
Me.GridView1.DataSource = dt
Me.GridView1.DataBind()
End If
End Sub
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) _
Handles GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim rowData As DataRowView = DirectCast(e.Row.DataItem, DataRowView)
e.Row.Cells(1).Attributes.Add("Title", rowData("Tel").ToString)
End If
End Sub
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles Me.Load
If Not IsPostBack Then
Dim dt As New DataTable
dt.Columns.Add("CustomerID", GetType(String))
dt.Columns.Add("CustomerNm", GetType(String))
dt.Columns.Add("TEL", GetType(String))
Dim row As DataRow
For i As Integer = 1 To 10
row = dt.NewRow
row("CustomerID") = i.ToString
row("CustomerNm") = "会社名" & i.ToString
row("TEL") = i & i & i & "-" & i & i & i & i & "-" & i & i & i & i
dt.Rows.Add(row)
Next
Me.GridView1.DataSource = dt
Me.GridView1.DataBind()
End If
End Sub
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) _
Handles GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim rowData As DataRowView = DirectCast(e.Row.DataItem, DataRowView)
e.Row.Cells(1).Attributes.Add("Title", rowData("Tel").ToString)
End If
End Sub
0 件のコメント:
コメントを投稿