这几天正忙着做一个平台,又一次用到了DATAGRID,不过这次对它的要求高了些,我想把它显示的一个动态的表(查询结果)中的任何一个ITEM 的详细信息显示在同一个叶面上。当然可以对其显示的详细信息的各项进行编辑等操作。下面是电击SELECT的按钮时的原代码。
DataGrid1.SelectedIndex = e.Item.ItemIndex '叶面上的值0~pagesize-1
Dim itemIndex As Integer
itemIndex = DataGrid1.SelectedIndex + DataGrid1.CurrentPageIndex * DataGrid1.PageSize '拿当前datagrid中的数据的index
If itemIndex < 0 Then
itemIndex = 0
End If
If e.CommandName.ToLower = "select" Then
Dim ta As DataTable
ta = getmember() '绑定数据getmember() 是我定义的一个从数据库中拿满足条件的ITEM
If Not IsDBNull(ta.Rows(itemIndex)("index")) Then显示你想看的任何一天记录的详细信息
index.Text = CStr(ta.Rows(itemIndex)("index"))
End If
If Not IsDBNull(ta.Rows(itemIndex)("userid")) Then
userid.Text = CStr(ta.Rows(itemIndex)("userid"))
End If
If Not IsDBNull(ta.Rows(itemIndex)("password")) Then
password.Text = CStr(ta.Rows(itemIndex)("password"))
End If
If Not IsDBNull(ta.Rows(itemIndex)("country")) Then
country.Text = CStr(ta.Rows(itemIndex)("country"))
End If
If Not IsDBNull(ta.Rows(itemIndex)("address")) Then
address.Text = CStr(ta.Rows(itemIndex)("address"))
End If
If Not IsDBNull(ta.Rows(itemIndex)("province")) Then
province.Text = CStr(ta.Rows(itemIndex)("province"))
End If
If Not IsDBNull(ta.Rows(itemIndex)("tel1")) Then
tel1.Text = CStr(ta.Rows(itemIndex)("tel1"))
End If
If Not IsDBNull(ta.Rows(itemIndex)("tel2")) Then
tel2.Text = CStr(ta.Rows(itemIndex)("tel2"))
End If
If Not IsDBNull(ta.Rows(itemIndex)("mobile")) Then
mobile.Text = CStr(ta.Rows(itemIndex)("mobile"))
End If
If Not IsDBNull(ta.Rows(itemIndex)("email")) Then
email.Text = CStr(ta.Rows(itemIndex)("email"))
End If
If Not IsDBNull(ta.Rows(itemIndex)("contact_person")) Then
contracter.Text = CStr(ta.Rows(itemIndex)("contact_person"))
End If
If Not IsDBNull(ta.Rows(itemIndex)("website")) Then
website.Text = CStr(ta.Rows(itemIndex)("website"))
End If
If Not IsDBNull(ta.Rows(itemIndex)("company")) Then
company.Text = CStr(ta.Rows(itemIndex)("company"))
End If
If Not IsDBNull(ta.Rows(itemIndex)("fax")) Then
fax.Text = CStr(ta.Rows(itemIndex)("fax"))
End If
If Not IsDBNull(ta.Rows(itemIndex)("member_type")) Then
membertype.Text = CStr(ta.Rows(itemIndex)("member_type"))
End If
If Not IsDBNull(ta.Rows(itemIndex)("member_type")) Then
membertype.Text = CStr(ta.Rows(itemIndex)("member_type"))
End If
If Not IsDBNull(ta.Rows(itemIndex)("member_type")) Then
membertype.Text = CStr(ta.Rows(itemIndex)("member_type"))
End If
If Not IsDBNull(ta.Rows(itemIndex)("last_modify_datetime")) Then
modifytime.Text = CStr(ta.Rows(itemIndex)("last_modify_datetime"))
End If
If Not IsDBNull(ta.Rows(itemIndex)("reg_datetime")) Then
regtime.Text = CStr(ta.Rows(itemIndex)("reg_datetime"))
End If