本文介绍了将列表保存到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

推荐答案


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

09-05 23:29