来自gridview上鼠标悬停的db的附加记录

时间:2014-12-18 12:44:53

标签: asp.net vb.net gridview

这里我在设计asp.net vb.net在线巴士预订系统时遇到了问题。   好吧,我试图从数据库中获取总线可用性信息,并在gridview中显示如下:" http://www.redbus.in/Booking/SelectBus.aspx?fromCityId=241&toCityId=122&doj=20-Dec-2014&busType=Any&opId=0"。                现在,如果你看到上面的链接,只需将鼠标悬停在" Depart"有一个列表将会提出,在该列表中还有一个附加信息显示来自一个城市的平均值有多少登机点,并且还显示了登机时间。                          所以,我一直试图让像redbus.in这样的列表,但没有运气。

所以,我也做了但无法获得整个记录。我只能得到一条记录。请看我的代码,请让我以正确的方式找到解决方案。  这是我的代码:

受保护的子gvEmployee_RowDataBound(ByVal sender As Object,_         ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)处理gvEmployee.RowDataBound

    '' BIND DATA WITH EACH ROW.
    If e.Row.RowType = DataControlRowType.DataRow Then
        Dim sDetails As String = "<span><h3>Boarding point And Droping point</h3></span>"
        Dim sdrEmpDet As SqlDataReader = GetDataReader( _
            "SELECT EmpID, BRpoint, BRTime,DRpoint,DRTime FROM Busdetails " & _
                "WHERE EmpID = " & e.Row.DataItem("EmpID").ToString)
        While sdrEmpDet.Read



            sDetails = sDetails & "<p><strong>Bus Code: </strong>&nbsp;&nbsp;&nbsp;" & _
                e.Row.DataItem("EmpID").ToString & "</p>"
            sDetails = sDetails & "<p><strong>Boarding Point: </strong></br></br>" & _
                sdrEmpDet.Item("BRpoint") & "</p>"
            sDetails = sDetails & "<p><strong> </strong></br>" & sdrEmpDet.Item("BRTime") & "</p>"

            sDetails = sDetails & "<p><strong>Dropping Point </strong></br>" & sdrEmpDet.Item("DRpoint") & "</p>"
            sDetails = sDetails & "<p><strong>Dropping Time </strong></br>" & sdrEmpDet.Item("DRTime") & "</p>"
            sDetails = sDetails & "<a href=VB.aspx?id=" & e.Row.DataItem("EmpID").ToString & _
                " title=more info>See more>></a>"

            ' BIND MOUSE EVENT (TO CALL JAVASCRIPT FUNCTION), WITH EACH ROW OF THE GRID.
            e.Row.Attributes.Add("onmouseover", "MouseEvents(this, event, '" & sDetails & "')")

            e.Row.Attributes.Add("onmouseout", "MouseEvents(this, event, '" & e.Row.DataItem("EmpID").ToString & "')")
        End While
        sdrEmpDet.Close() : sdrEmpDet = Nothing

    End If

1 个答案:

答案 0 :(得分:1)

虽然我不确定这是实现这一目标的最佳方法,但您的特殊问题是您需要在关闭while循环后添加鼠标悬停事件