Can I pass more than 2 parameters or an array with onCommand event in asp.net?
the question is above and it is short. I am tryi开发者_运维百科ng to pass more parameters through a button in a repeater itemtemplate
I would append the values to a string with a delimeter, like this:
CommandArgument='<%# String.Format("{0}|{1}|{2}", Eval("Column1"), Eval("Column2"), Eval("Column3"))'%>
When you get into the event handler, just split the string at the delimeter, like this:
var columnList = e.CommandArgument.Split('|');
The CommandArgument property takes a string. So you could put several values into that property in a comma separated format, e.g:
button.CommandArgument = "param1,param2,param3";
Then in the OnClick event handler, simply split the CommandArgument property:
var parameters = e.CommandArgument.Split(',');
I used a dumb way to walk around this problem.
pass all the stuff into CommandArgument and use string.split to get the parameter array.
CommandArgument='<%# Eval("PersonId") + ";" + Eval("PersonName") %>'
string[] paras = argu.Split(';');
精彩评论