前臺(tái)頁(yè)面代碼:
1.在GridView模板列中,添加LinkButton控件(只要是模板控件就行);
2.在LinkButton控件的屬性:
CommandName屬性:del/editor/search/add //可以自定義
CommandArgument屬性:<%#Eval("ID")%>要綁定的值
后臺(tái)CS代碼:
protected void gdvBusiness_RowCommand(object sender, GridViewCommandEventArgs e)
{
switch (e.CommandName.ToLower())
{
case "del"://刪除
BusinessManager.Del(Convert.ToInt32(e.CommandArgument));
BindGridView();
break;
case "editor"://修改
Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>location.href='BuesinessEditor.aspx?id=" + int.Parse(e.CommandArgument.ToString()) + "';</script>");
break;
case "search"://查詢
Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>location.href='BuesinessInfo.aspx?id=" + int.Parse(e.CommandArgument.ToString()) + "';</script>");
break;
case "add"://增加
Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>location.href='BuesinessAdd.aspx';</script>");
break;
default:
break;
}
}
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)
點(diǎn)擊舉報(bào)。