Hi,
i am developting one question paper. now i want to save the question no and answer in a session using arraylist. how can i save . in .net i am using this code i stroed both question no and answer . now i want the same code in silverlight. but in silverlight i am not getting both arraylist and sessions . how can i achieve this one.
private void SaveCheckedValues()
{
ArrayList userdetails1 = new ArrayList();
ArrayList userdetails2 = new ArrayList();
ArrayList userdetails3 = new ArrayList();
ArrayList userdetails4 = new ArrayList();
int index = -1;
foreach (GridViewRow gvrow in GV_Questionpaper.Rows)
{
index = (int)GV_Questionpaper.DataKeys[gvrow.RowIndex].Value;
bool result1 = ((RadioButton)gvrow.FindControl("RBtn_Option1")).Checked;
bool result2 = ((RadioButton)gvrow.FindControl("RBtn_Option2")).Checked;
bool result3 = ((RadioButton)gvrow.FindControl("RBtn_Option3")).Checked;
bool result4 = ((RadioButton)gvrow.FindControl("RBtn_Option4")).Checked;
if (Session["CHECKED_ITEMS1"] != null)
{
userdetails1 = (ArrayList)Session["CHECKED_ITEMS1"];
}
if (Session["CHECKED_ITEMS2"] != null)
{
userdetails2 = (ArrayList)Session["CHECKED_ITEMS2"];
}
if (Session["CHECKED_ITEMS3"] != null)
{
userdetails3 = (ArrayList)Session["CHECKED_ITEMS3"];
}
if (Session["CHECKED_ITEMS4"] != null)
{
userdetails4 = (ArrayList)Session["CHECKED_ITEMS4"];
}
if (result1)
{
if (!userdetails1.Contains(index))
userdetails1.Add(index);
}
else
{
userdetails1.Remove(index);
}
if (result2)
{
if (!userdetails2.Contains(index))
userdetails2.Add(index);
}
else
{
userdetails2.Remove(index);
}
if (result3)
{
if (!userdetails3.Contains(index))
userdetails3.Add(index);
}
else
{
userdetails3.Remove(index);
}
if (result4)
{
if (!userdetails4.Contains(index))
userdetails4.Add(index);
}
else
{
userdetails4.Remove(index);
}
Thanks
P.Nagaraju
Loading

Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Aug 23, 2011, 12:23 AM EDT
There is no session in Silverlight, We have to do as this article
VulpesRank #55 · 29.2K reputationPosted Aug 23, 2011, 12:25 AM EDT
Check out : http://www.dotnetspider.com/Silverlight-Tutorial-316.aspx
nagaraju84 reputationPosted Aug 23, 2011, 1:14 AM EDT
i want to save the question no and answer and i have to maintain them in session .can anybody send me the code for storing the values and populating the values
Thanks
P.Nagaraju
VulpesRank #55 · 29.2K reputationPosted Aug 23, 2011, 2:20 AM EDT
nagaraju84 reputationPosted Aug 23, 2011, 3:49 AM EDT
i am not getting arraylist also . i am writing in xaml.cs file. the silverlight application will not support the arraylist also. can u please tell me solution for that also.
if i write the code in wcf service i could not find my datagrid contol . so i have to write in xaml.cs file
Thanks
P.Nagaraju
VulpesRank #55 · 29.2K reputationPosted Aug 23, 2011, 4:28 AM EDT
You'll have to use the generic List class instead which works much the same but is strongly typed.
So, if you're adding strings to your ArrayList you'll need to add them to a List
ArrayList list = new ArrayList();
list.Add("nagaraju"); // store
string user = (string)list[0]; // retrieve
is equivalent to:
List
list.Add("nagaraju"); // store
string user = list[0]; // retrieve (no need for the cast, now)
nagaraju84 reputationPosted Aug 23, 2011, 8:13 PM EDT
i have one doubt is it possible to maintain state in silverlight? can u please confirme me once.
Thanks
P.Nagaraju
VulpesRank #55 · 29.2K reputationPosted Aug 24, 2011, 5:45 AM EDT
However, you can store information on the client machine using isolated storage. Check out this article:
http://blogs.silverlight.net/blogs/msnow/archive/2008/07/16/tip-of-the-day-19-using-isolated-storage.aspx