repeater控件中做了个删除列的绑定表达式
repeater控件中做了个删除列
html中的代码:
<td align= "center ">
<a onClick= 'return confirm( "您确定删除! "); <%#Delete(((DataRowView)Container.DataItem)[ "ID "]);%> ' href= "# ">
</a>
</td>
.cs文件中的代码:
public void Delete(int ID)
{
//根据传入的ID作删除。
}
上面代码运行出错: 编译器错误信息: CS1026: 应输入 )
如果我不绑定表达式,即
<a onClick= 'return confirm( "您确定删除! "); <%#Delete(2);%> ' href= "# ">
直接给Delete() 传入“2”,能够正常执行删除,可能 " <%# ...%> "写的不对,请指教!
------解决方案--------------------1 先在Repeater中写一个OnItemCommand
<asp:Repeater ID= "Repeater " runat= "server " OnItemCommand= "op_ItemCommand " >
2 再在删除那个按钮写一个CommandName
<asp:LinkButton runat= "server " ID= "zssc " ToolTip= "删除发布页面 " CommandName = "Del " OnClientClick= "return confirm( '确定要删除新闻的发布页面? ') "> </asp:LinkButton>
3 CS代码中写下面的东东
protected void op_ItemCommand(object sender, RepeaterCommandEventArgs e)
{
switch (e.CommandName)
{
case "Del ":
//操作的代码!
break;
}
}