c# - Create MVC querystring from a List -


is possible to, in code, generate querystring binded controller variable this

mycontroller(list<long?> querylist) { 

//i want querylist bound using defualt model binder. don't know how generate source string accepted here }

in code, need generate querystring in function this

generatebindable(list<long?> list) {     string listquerystring="";     ....     //what need here? } 

i trying find built-in function this, actionlink helper did not expected. resulted in this

my/url/path?a=system.collections.generic.list%601%5bsystem.nullable%601%5bsystem.int64%5d%5d

seems did tostring on collection, won't work.

you can achieve creating route value dictionary in controller.

var rv = new routevaluedictionary(); int = 0; querylist.foreach(t => { rv.add("a[" + (++i) + "]", t); }); 

lets add route value dictionary viewbag (or model). i'm going use viewbag demonstration purposes recommend use model instead.

viewbag.routevalues = rv; 

finally in view create action link using route value dictionary.

 @html.actionlink("about", "about", (routevaluedictionary)viewbag.routevalues) 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -