我创建了一个包含字符串“ test ”的方法来保存我的SqlCommand查询。 test ='201813'
protected void gwPlanning_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.Cells.Count > 0)
{
//Translate header text
if (e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells[12].Text = test.ToString();
}
}
}
现在的问题是如何在以下 rowdatabound事件中重用此字符串?
e.Row.Cells[12].Text = **test.ToString();
我正在尝试使用{{1}}
任何人都可以帮我解决我的错误吗?
答案 0 :(得分:1)
在您的代码中,字符串变量test
是temp()
的局部变量,如果您想在gwPlanning_RowDataBound
中使用它,您必须创建函数{{ 1}}返回一个字符串值,或者你必须将值保存在一个全局变量中。
temp()返回字符串值。
代码:
temp