nagaraju

nagaraju

  • NA
  • 87
  • 129.7k

Maintaining the state for all controls in datagrid in Silverlight

Aug 25 2011 12:34 AM
Hi,

i am developting one question paper. now i want to save the question no and answer in a session using arr  aylist. 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);
  }



Answers (3)