网格错误,请参阅 [英] grid error please see
本文介绍了网格错误,请参阅的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望使用值gridview保存会话,但无法保存
*我是定义函数;
请看.
i want value gridview to save Session but cant
* i am Definition function;
plaese see.
public string Add()
{
ArrayList arr;
if (Session["mycart"] != null)
{
arr = (ArrayList)Session["mycart"];
}
else
{
arr = new ArrayList();
Session["mycart"] = arr;
}
EmailTextBox.text = EmailGridView.rows(0).cells(1).text.ToString
CShoppingCartItem item = new CShoppingCartItem();
//item.ProductID = int.Parse(ReciveId);
//int.Parse(GridView1.Rows[0].Cells[2].Text.ToString());
<big> item.ProductName = GridView1.Rows[1].Cells[1].Text;</big>
.// item.Quantity = 1;
arr.Add(item);
return "s";
}
错误:
error:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
推荐答案
是将网格视图绑定到arraylist. > 如果是,那么
Are You binding your gridview to arraylist.
if yes then
else
{
arr = new ArrayList();
Session["mycart"] = arr;
}
当您将arr存储到会话中之前,必须先初始化arraylist arr
when you store arr to session, before that you have to initialize arraylist arr
check the index of rows and cells. check if there is any value or not.
try 0 instead of 1 in 'rows[1]'.
like:-
GridView1.Rows[0].Cells[1].Text;
这篇关于网格错误,请参阅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文