我是新來的C#事件,以便道歉,如果我問這個問題的方法是不正確的。怎麼寫onrowcommand
我已經添加在網格視圖按鈕現在我想執行鍼對C#按鈕編碼一些特定的動作..但我無法點擊按鈕,這就是爲什麼我不能寫對按鈕事件的代碼。
請告訴我怎麼寫針對網格按鈕事件代碼???
這裏是我的編碼:
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnDecline" runat="server" Text="Decline" onrowcommand="decline" />
</ItemTemplate>
</asp:TemplateField>
這裏是C#代碼:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Sherserve.BusinessLogicLayer;
using Sherserve.CustomTypeLayer;
namespace SherserveLeaveManagementSystem
{
public partial class LMSAdminPanel : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
LMSManager leavestatus = new LMSManager();
int emplid = Convert.ToInt32(Session["EmployeeID"]);
List<EmployeeLeave> leaverecord = leavestatus.GetLeaveRecord(emplid);
GridView1.DataSource = leaverecord;
GridView1.DataBind();
}
}
protected void GridView1_PageIndexchanging(object sender, GridViewPageEventArgs e)
{
LMSManager leavestatus = new LMSManager();
int emplid = Convert.ToInt32(Session["EmployeeID"]);
List<EmployeeLeave> leaverecord = leavestatus.GetLeaveRecord(emplid);
GridView1.DataSource = leaverecord;
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataBind();
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
我在C#中新的,請不要介意我問這個問題的方法是長或不正確的。
感謝
好一個!如果你想傳遞參數'CommandName =「Delete」CommandArgument ='<%#Eval(「Id」)%>' – kbvishnu