asp.net - Unable to cast object of type 'System.Collections.Generic.List -


i getting error

unable cast object of type 'system.collections.generic.list`1[transtripleg]' type 'system.data.datatable'.

and can't seem figure out how resolve it. error occurs @ datatable dttable = in code below.

if (!string.isnullorempty(request.querystring["editmode"])) {     datatable dtupdate = (datatable)session["triprecords"];     datarow[] customerrow = dtupdate.select("legid = '" + slegid.tostring() + "'"); 

i think casting type datatable, still error.

you need cast session["triprecords"] list<transtripleg> instead of datatable

var collection = (list<transtripleg>)session["triprecords"]; var legs = collection.where(c => c.legid == slegid); 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -