日期:2014-05-17 浏览次数:20491 次
protected void btnAddCategory_Click(object sender, EventArgs e)
{
string strCommand = "window.open('CategoryManage/CategoryAddition.aspx')";
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", strCommand, true);
}
protected void btnEditCommand(object sender, CommandEventArgs e)
{
string strCommand = "window.open('CategoryEdit.aspx?ID=" + e.CommandName.ToString() + "')";
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", strCommand, true);
}
<asp:LinkButton ID="lnkbtnAdd" runat="server" Text="添加" CommandName="Add"></asp:LinkButton>
<asp:LinkButton ID="lnkbtnEdit" runat="server" Text="编辑" CommandName="Edit" CommandArgument='<%#Eval("id") %>'></asp:LinkButton>
------解决方案--------------------
或者还应该把CommandName当作一个参数传过去 用作在子页面的时候
判断是执行添加操作还是编辑操作
------解决方案--------------------
额外的新增一个参数传,通过参数来进行判断是新增还是编辑操作
------解决方案--------------------
CategoryEdit.aspx?
CategoryEdit.aspx?ID=123
if(request.QueryString["ID"]!=null)
{
编辑
}
else
{
添加
}
------解决方案--------------------
直接获取ID的值,有值就是编辑,没值就是新增
或者加一个type 参数 type=New 新增 type=Edit 编辑。
在页面获取这个参数即可。。
------解决方案--------------------
顶楼上,通过传过去的参数来判断是否是新增还是编辑。