【问题标题】:Gridview Rowcommand cell to public stringGridview Rowcommand 单元格到公共字符串
【发布时间】:2018-04-23 07:44:47
【问题描述】:

我有一个带有 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;  
}

【问题讨论】:

  • 嗯,this.Temp = temp; 你想达到什么目的?
  • 是的.....要么将 temp 传递给任何需要的东西,因为范围当前意味着变量一旦生成就会消失。你可以让它成为课堂的一部分

标签: c# asp.net string gridview rowcommand


【解决方案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;
}

【讨论】:

  • 看看这有多“容易” :) 我每天都学到新东西。谢谢!
猜你喜欢
  • 2012-04-11
  • 1970-01-01
  • 2012-06-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多