【发布时间】:2011-12-16 07:30:27
【问题描述】:
我正在网格视图的行数据绑定上编写以下代码,但我没有收到链接按钮的点击事件
Protected Sub CoolGRDSourcedDetails_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles CoolGRDSourcedDetails.RowDataBound
Dim iLoop As Integer
Dim lbtnCountDetails As New LinkButton
e.Row.Cells.RemoveAt(1)
If e.Row.RowType = DataControlRowType.Header Then
For iLoop = 1 To (dscolumns / 2) - 1
e.Row.Cells(iLoop).Attributes.Add("colspan", "2")
If iLoop = 1 Then
e.Row.Cells(iLoop).Text = "Self"
Else
e.Row.Cells(iLoop).Text = "Child" & iLoop - 2
End If
Next
e.Row.Cells(iLoop).Text = "Total"
ElseIf e.Row.RowType = DataControlRowType.DataRow Then
For iLoop = 1 To dscolumns - 2
If iLoop Mod 2 <> 0 Then
e.Row.Cells(iLoop + 1).Text = Format(IIf(CInt(e.Row.Cells(iLoop).Text) <> 0, (CInt(e.Row.Cells(iLoop).Text) / value) * 100, 0), "0.00") & "%"
If CInt(e.Row.Cells(iLoop).Text) <> 0 Then
e.Row.Cells(iLoop).Controls.Add(lbtnCountDetails)
lbtnCountDetails.Text = e.Row.Cells(iLoop).Text
lbtnCountDetails.CommandArgument = "strstatus"
lbtnCountDetails.Attributes.Add("OnClick", "lbtnCountDetails_Click")
End If
End If
Next
End If
End Sub
'点击事件在这里
Protected Sub lbtnCountDetails_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim strStatus As String = CType(sender, LinkButton).CommandArgument
End Sub
【问题讨论】: