将列表保存到viewstate c# [英] save list into viewstate c#

查看:75
本文介绍了将列表保存到viewstate c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我想在每次单击添加按钮时将项目添加到列表中,但每次回发后都会重置列表。如何在回发之间保留列表中的数据?



Hi,

I want to add an item to the list every time the Add button is clicked, but the list is reset after every postback. How can I keep the data in the list between postbacks?

List<KeyValuePair<string, string>> SelList = new List<KeyValuePair<string, string>>();

for (int r = 0; r <= arrAdd.Length - 1; r++)
{
if (arrAdd[r, 0] == c.ID)
{
SelList.Insert(fldCount, new KeyValuePair<string, string>(arrAdd[r, 1], c.ID));
fldCount += 1;
break;
}
}





谢谢



Thanks

推荐答案

将其保存在会话中: MSDN [ ^ ]
Save it in the Session: MSDN[^]


这篇关于将列表保存到viewstate c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆