如何在asp.net Gridview中获取以前单击的元素

时间:2015-03-31 09:39:15

标签: asp.net vb.net visual-studio-2008

我在gridview中有一个itemtemplate linkbutton。我想在linkbutton_Onclick事件中设置点击的链接按钮字体粗体。

Protected Sub lblArtId_Onclick(ByVal sender As Object, ByVal e As EventArgs)
    Dim clickedRow As GridViewRow = TryCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
    lblArtId_temp_lnk = DirectCast(clickedRow.FindControl("lblArtId"), LinkButton)
    'ViewState("lblArtId_temp_lnk") = lblArtId_temp_lnk
    ' lblArtId_temp_lnk.Font.Bold = False
    Dim qry As String = ""
    Dim str_Qry As String = String.Empty
    Dim dt As DataTable = New DataTable
    Dim dt_new As DataTable = New DataTable
    Dim txt As String = ""
    Dim obj As GridViewGroup

    Dim lblArtId_lnk As LinkButton = DirectCast(clickedRow.FindControl("lblArtId"), LinkButton)

    If ViewState("lblArtId_temp_lnk_cnt") > 0 Then
        lblArtId_temp_lnk.Font.Bold = False
    End If

    ViewState("lblArtId_temp_lnk_cnt") += 1

End Sub

即,先前点击的链接按钮设置为正常,当前点击的链接按钮设置为字体粗体
建议我找一个解决方案。

提前致谢

0 个答案:

没有答案