In ASPX Page:
<asp:templatefield headertext="Cancel" headerstyle-horizontalalign="Center" itemstyle-horizontalalign="Center" xmlns:asp="#unknown">
<itemtemplate>
<asp:linkbutton id="CancelButton" runat="server" imageurl="~/images/Cancel.jpg" commandargument="e.Row.RowIndex.ToString()" commandname="Cancel" />
</itemtemplate>
</asp:templatefield>
In CodeBehind page
protected void MainGridView_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton editButton = (LinkButton)(e.Row.FindControl("CancelButton"));
editButton.CommandArgument = "You Own Arguments";
}
}
protected void MainGridView_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Edit")
{
if (System.Windows.Forms.MessageBox.Show("Sure want to Cancel Appointment?", "Cancel Appointment",System.Windows.Forms.MessageBoxButtons.YesNo,System.Windows.Forms.MessageBoxIcon.Question) == DialogResult.Yes)
{
systemBusinessLayer = new BusinessLayer();
systemBusinessLayer.cancelAppointmentByEmployee(Convert.ToInt32(Session["SlotID"]), Convert.ToInt32(Session["EmpRecNr"]));
}
}
}