i have session in controller follow
session["fulldata"] = data;
which stores data name,id,city etc;
it stores multiple rows of such data.
how how access or check if row has particular name in it, in view?
eg :
@if(session("fulldata").has("abc")) { //do }
i want check name each row in session. appreciated
first need cast session("fulldata")
type session store collection object
type.
list<customclass> data = (list<customclass>)session("fulldata");
if data collection can use linq enumerable.any search
@if(data.any(d=>d.yourattr1 == 'abc' || d.yourattr2 == 'abc')) { //do }
as additional note please not use session unnecessarily big data session need space on server , user/session increase adversely effect performance.
Comments
Post a Comment