我是 c# 的新手,如果我的提问方式不正确,我深表歉意。
我已经在网格视图中添加了按钮,现在我想对 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# 新手,请不要介意我的提问方式是否长或不正确。
谢谢