【问题标题】:Hyperlink in DataField of GridView ASP.netGridView ASP.net 的 DataField 中的超链接
【发布时间】:2014-04-22 15:25:42
【问题描述】:

我有一个带有行和行的 GridView。在行中我输入了姓名(例如 John、Jack、Paul...),在行中输入了统计信息(例如工作时间、薪水、状态...)。我不知道如何在名称上设置超链接以打开包含所选人员的整个个人资料的页面。我想点击 Paul 并被重定向到另一个页面,其中包含整个个人资料以及照片和其他信息。每个名称必须有不同的超链接。我尝试直接通过 Access 进行操作,但没有成功。

谢谢

理查德

【问题讨论】:

  • 如果您为 GridView 提供标记可能会有所帮助。请使用该信息更新您的问题。另外,你为什么把它标记为ms-access?这似乎无关。

标签: asp.net gridview hyperlink


【解决方案1】:

您应该在gridview 中使用这行代码。在gridview 中添加超链接并编辑此代码以使其正常运行。 <asp:hyperlinkfield text="Name?" datanavigateurlfields="Id" datanavigateurlformatstring="~\Persondetails.aspx?id={0}" //passing the Id to new page
headertext="Name" target="_blank" />

您应该在第二页编写这样的代码,以确保在第二页显示所选名称显示所有详细信息。

 Dim nameID As String
    nameID = Request.QueryString("id")
    Dim nameqstring As Integer = Convert.ToInt32(nameID)

要显示所选第二页中的数据,请使用此页面

 Using sqlComm As New MySqlCommand()
            sqlComm.Connection = sqlConn
            With sqlComm
                .CommandText = "select * From table where NameId=@nameId"
                .Parameters.AddWithValue("@nameId", nameID)
                Try
                    Dim sqlReader As MySqlDataReader = sqlComm.ExecuteReader()
                    While sqlReader.Read()
                        Label1.Text = sqlReader("Name").ToString()
                        Label2.Text = sqlReader("Job").ToString()
                        Label3.Text = sqlReader("Salary").ToString()
                        Label4.Text = sqlReader("Workhours").ToString()
                        Label5.Text = sqlReader("Status").ToString()
End While End Using End Using

希望对你有很大帮助。

【讨论】:

    猜你喜欢
    • 2011-12-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-01
    • 2013-04-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多