使用会话更新gridview [英] gridview updation using session
本文介绍了使用会话更新gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
GridViewRow row = GridView1.Rows[e.RowIndex];
if (Session["dt"] != null)
{
DataSet dt1 = (DataSet)Session["dt"];
dt1.Tables[0].Rows[row.DataItemIndex][0] = ((TextBox)(row.Cells[1].Controls[0])).Text;
dt1.Tables[0].Rows[row.DataItemIndex][1] = ((TextBox)(row.Cells[2].Controls[0])).Text;
dt1.Tables[0].Rows[row.DataItemIndex][2] = ((TextBox)(row.Cells[3].Controls[0])).Text;
dt1.Tables[0].Rows[row.DataItemIndex][3] = ((TextBox)(row.Cells[4].Controls[0])).Text;
GridView1.EditIndex = -1;
binddata();
}
if (Session["key"] != null)
{
Response.Write("hello");
DataSet dt2 = (DataSet)Session["key"];
dt2.Tables[0].Rows[row.DataItemIndex][0] = ((TextBox)(row.Cells[1].Controls[0])).Text;
dt2.Tables[0].Rows[row.DataItemIndex][1] = ((TextBox)(row.Cells[2].Controls[0])).Text;
dt2.Tables[0].Rows[row.DataItemIndex][2] = ((TextBox)(row.Cells[3].Controls[0])).Text;
dt2.Tables[0].Rows[row.DataItemIndex][3] = ((TextBox)(row.Cells[4].Controls[0])).Text;
GridView1.EditIndex = -1;
binddata();
}
我发现错误只有第一行对其他人进行了很好的更新我发现错误在session ["key"]中的位置1没有行..(session ["dt"]运行良好,它是一个空的数据集)
only the first row is updated well for others i found error There is no row at position 1 in session["key"].. (the session["dt"] is working well it is an empty dataset")
推荐答案
好吧,简单的错误指出Session["key"]
的数据集只包含一行.
您需要使用DEBUGGER并查看自己存储在Session["key"];
中的内容,并验证它存储的数据集包含的行数比您期望的要多,并且已为其编写了代码. (预计这里有4行)
Well, error simple states thatSession["key"]
has a dataset that has only one row in it.
You need to use DEBUGGER and see yourself what is stored inSession["key"];
and verify that it stored a dataset that has more that many rows as much you expect and have written code for. (Here 4 rows expected)
这篇关于使用会话更新gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文