【发布时间】:2010-01-11 16:40:23
【问题描述】:
我是 C# 新手,在 VB 中我可以执行以下操作:
Protected Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.ItemCommand
If e.CommandName = "CommandName" Then
Dim label1 As Label = e.Item.FindControl("label1")
Response.Write(label1.Text))
End If
End Sub
在 C# 和 RowCommand 中,我无法使用 findcontrol 访问控件值。我想获取两个标签的值,以便在调用 rowcommand 中的方法时可以使用它们
更新: 当我这样做时在 C# 中
Label label1 = (Label)e.Item.FindControl("label1");
或
Label label1 = (Label)e.Row.FindControl("label1");
我没有可用的行或项目
【问题讨论】:
-
您在 C# 中处理与在 VB 中相同的事件吗?
标签: c# asp.net findcontrol