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
VulpesPosted Aug 24, 2011, 9:45 AM
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
nagarajuPosted Aug 24, 2011, 12:13 AM
i have one doubt is it possible to maintain state in silverlight? can u please confirme me once.
Thanks
P.Nagaraju
VulpesPosted Aug 23, 2011, 8:28 AM
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)
nagarajuPosted Aug 23, 2011, 7:49 AM
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
VulpesPosted Aug 23, 2011, 6:20 AM
nagarajuPosted Aug 23, 2011, 5:14 AM
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
VulpesPosted Aug 23, 2011, 4:25 AM
Check out : http://www.dotnetspider.com/Silverlight-Tutorial-316.aspx
Jaganathan BantheswaranPosted Aug 23, 2011, 4:23 AM
There is no session in Silverlight, We have to do as this article