0

我有一个带有 rowcommand 事件的 gridview。

我希望在temp我的行命令之外使用字符串的值。这可能吗?

protected void gwActivity_RowCommand(object sender, GridViewCommandEventArgs e)
{
   GridViewRow row = ((e.CommandSource as Control).NamingContainer as GridViewRow);
   string temp = row.Cells[1].Text;  
}
4

1 回答 1

1

您可以在课堂上创建一个私有字段,例如:

private string _temp;

然后将您的temp字符串分配给它:

protected void gwActivity_RowCommand(object sender, GridViewCommandEventArgs e)
{
   GridViewRow row = ((e.CommandSource as Control).NamingContainer as GridViewRow);
   string temp = row.Cells[1].Text;  

   _temp = temp;
}
于 2018-04-23T07:50:01.800 回答