C#语法 在HTML中的绑定代码

来源:百度知道 编辑:UC知道 时间:2024/05/27 03:15:05
<%#IIf(Container.ItemIndex + (10 * (PageSize - 1)) = 0, "主贴", "回复" & Container.ItemIndex + (10 * (PageSize - 1)))%></strong>

错误:运算符“&”无法应用于“string”和“int”类型的操作数
错误:当前上下文中不存在名称“IIf”
IIF是不行的,改三元运算符?:

字符串连接是吗,用+
<%#IIf(Container.ItemIndex + (10 * (PageSize - 1)) = 0, "主贴", "回复" + Container.ItemIndex + (10 * (PageSize - 1)))%></strong>

错误:运算符“&”无法应用于“string”和“int”类型的操作数
字符串连接符是“+”,不是“&”。

错误:当前上下文中不存在名称“IIf”
没有IIf的语法,而且也不能用“=”来判断,要用“==”。

三元运算符表达式如下修改:
<%# (Container.ItemIndex + (10 * (PageSize - 1)) == 0) ? "主贴" : ("回复" + (Container.ItemIndex + (10 * (PageSize - 1)))) %>