我是 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");
我没有可用的行或项目