前臺(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"://查詢(xún)
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; } } |
|
來(lái)自: 二寶么么噠 > 《asp.net(C#)》