<asp:CheckBox oncheckedchanged="chk1_CheckedChanged" ID=chk1 CssClass='<%# Eval("UserID") + "," + Eval("IsB") %>' runat="Server"/>
我的页面上有这个复选框..如果我需要在CssClass属性中分配这两个CommandArgument值,即
&lt;%#Eval(“UserID”)%&gt;和&lt;%#Eval(“IsB”)%&gt;在我的代码后面到两个字符串 ..我怎么做?
protected void chk1_OnCheckChanged(object sender, EventArgs e)
{
string s1 = "Need the first value from Command argument here";
string s2 = "Need the second value from Command argument here";
}
如何获取复选框???
的CssClass属性中传递的命令参数值答案 0 :(得分:1)
CssClass='<%# string.Format("{0},{1}", Eval("UserID"), Eval("IsB")) %>'
在您的代码中:
protected void chk1_OnCheckChanged(object sender, EventArgs e)
{
var chk = (CheckBox)sender;
var tokens = chk.CssClass.Split(',');
string userId = tokens[0];
string isB = tokens[1];
}