Click here to Skip to main content
15,894,012 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?

C#
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
Posted

1 solution

Save it in the Session: MSDN[^]
 
Share this answer
 
Comments
PleaseHelpCP 1-Jun-13 6:10am    
What if i use viewstate? can you help with reference link for viewstate?
OriginalGriff 1-Jun-13 7:03am    
My name is OriginalGriff, not OriginalGoogle.
PleaseHelpCP 1-Jun-13 7:38am    
i know thats why i asked can you help
OriginalGriff 1-Jun-13 8:13am    
The implication from my previous comment is: I am not here to google for you.
Have you tried looking yourself, at all?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900