全部博文(64)
分类: 嵌入式
2012-10-31 17:25:09
方法1:
Text="删除" CommandArgument='<%#Eval("ClassID")%>' CommandName="DeletePClass1"
OnCommand="DelArrange" OnClientClick="return confirm('确定要删除该分类信息吗?');" >
Text="删除" CommandArgument='<%#Eval("ClassID")%>' CommandName="DeletePClass2"
OnCommand="DelArrange" OnClientClick="return confirm('确定要删除该分类信息吗?');" >
#region 编辑
protected void EditArrange(object sender, CommandEventArgs e)
{
string id = e.CommandArgument.ToString();
string flag = e.CommandName;
string sql = string.Empty;
if (flag == "DeletePClass1")
{
sql = "delete tb_pclass1 where id=@id";
}
else if (flag == "DeletePClass2")
{
sql = "delete tb_pclass2 where id=@id";
}
else if (flag == "DeletePClass3")
{
sql = "delete tb_pclass3 where id=@id";
}
else
{
sql = "delete tb_pclass4 where id=@id";
}
}
#endregion
方法2:
Text="保存并返回" runat="server" OnClick="btn_Save">">
Text="保存并新建" runat="server" OnClick="btn_Save">
后台aspx.cs的一个事件
protected void
btn_Save(object sender, EventArgs e)
{
if (((Button)sender).ID == "SaveAndBack")//关键是((Button)sender).ID 这个把sender转换成Button类型的,然后在获取按钮的ID
{
Response.Write("你点你的是保存并返回按钮");
}
else //我这里只有两个按钮不是1就是2 你根据实际情况自己变通一下if
{
Response.Write("你点的保存并新建按钮");
}
}
http://dicky2345.blog.163.com/blog/static/300741902008113003040795/