代码: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
rqid = Request.QueryString("id")
If rqid <> "" Then
comdstr = "select * from contact where id=" & rqid
comd = New SqlCommand(comdstr, conn)
conn.Open()
rdp = comd.ExecuteReader
If rdp.Read() Then
contactid.Text = rdp("contactid").ToString
name.Text = rdp("name").ToString
End If
conn.Close()
end sub
HTML:
DATAGRID中columns列:
<Columns>
<asp:HyperLinkColumn Target="_self" DataNavigateUrlField="id" DataNavigateUrlFormatString="contact.aspx?id={0}"
DataTextField="contactid" HeaderText="用户名"></asp:HyperLinkColumn>
<asp:BoundColumn DataField="name" ReadOnly="True" HeaderText="姓名"></asp:BoundColumn>
</Columns>
TEXTBOX:
用 户 名:<asp:textbox id="contactid" runat="server"></asp:textbox>
联系人名:<asp:textbox id="name" runat="server"></asp:textbox>