mmalik15
asked on
how to store and retrieve Linq List into session variable in c#
This is how i am storing my linq list into session. How would I retrive it back from session
DataClassesDataContext myContext = new DataClassesDataContext();
var QuestionList = myContext.sp_GetQuestionsB yChapterID (Session[" QuizID"].T oString()) .ToList();
Session["QuestionsList"] = QuestionList;
I have tried something like this to retrive it back from session
var QuestionList= Session["QuestionsList"] ;
int QuestionID = (int)QuestionList[CurrentP os].Questi onID;
this is giving me an error
"Cannot apply indexing with [] to an expression of type 'object'"
DataClassesDataContext myContext = new DataClassesDataContext();
var QuestionList = myContext.sp_GetQuestionsB
Session["QuestionsList"] = QuestionList;
I have tried something like this to retrive it back from session
var QuestionList= Session["QuestionsList"] ;
int QuestionID = (int)QuestionList[CurrentP
this is giving me an error
"Cannot apply indexing with [] to an expression of type 'object'"
ASKER
thanks for comment
I store QuestionList in var like this, var QuestionList but using it as an arraylist. Can we convert the session into arraylist?
I store QuestionList in var like this, var QuestionList but using it as an arraylist. Can we convert the session into arraylist?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If "QuestionList" is "List<Question>", you can retrieve as follows
Open in new window
-Kusala