2
假设您将数据保存到动态隐藏字段中,该字段是在处理某些回发事件期间动态创建的。回发后的动态hiddenfield
什么是在回发时从此字段中检索它的最佳方法(除了搜索此隐藏字段的密钥请求,然后如下面的代码中检索相应的值)?
protected void Button2_Click(object sender, EventArgs e)
{
bool found = false;
for (int i=0; i<this.Request.Form.Keys.Count; i++)
{
string item = this.Request.Form.Keys[i];
if (item=="Hidden1")
{
Literal6.Text = Request.Form.GetValues(i)[0];
found = true;
}
}
if (found==false)
{
Literal6.Text = "Hidden1 is not found";
}
}
提示:(找到== false)可以写成(!found) – 2010-09-18 05:48:33