Hi
I have below code but rowcommand not getting executed
protected void gr_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
if (e.Row.RowType != DataControlRowType.DataRow)
return;
e.Row.Cells[0].HorizontalAlign = HorizontalAlign.Center;
for (int i = 8; i < e.Row.Cells.Count - 1; i++)
{
string cellValue = e.Row.Cells[i].Text;
var row = (DataRowView)e.Row.DataItem;
var currentPerson = row[0].ToString();
var currentDate = row.DataView.Table.Columns[i];
var commandArgument = currentPerson + ":" + currentDate;
LinkButton button = new LinkButton();
button.Text = cellValue;
button.CommandName = "Select";
button.CommandArgument = commandArgument;
button.OnClientClick = "GetModuleData(this)";
if (cellValue.ToUpper().Trim() == "A")
{
button.CssClass = "badge badge-danger";
}
}
}
}
***************************************
protected void grdPlanning_RowCommand(object sender, GridViewCommandEventArgs e)
{
try
{
if (e.CommandName == "Select")
{
BALBooks bALBooks = new BALBooks();
BALStudents bALStudents = new BALStudents();
StudentDetail Result = bALStudents.GetStudentDetailByLoginID(bALStudents.GetStudentIDByMobile(hdfMobile.Value));
ltrlHead.Text = Result.Name;
ltrlHead.Text = ltrlHead.Text + " : " + bALBooks.GetBookTitle(Convert.ToInt32(hdfBookId.Value));
BindData(Convert.ToInt32(hdfBookId.Value), Result.LoginCode);
}
}
catch (Exception ex)
{
Utility.SaveErrorLog(ex.Message, System.IO.Path.GetFileName(Request.Path), System.Reflection.MethodBase.GetCurrentMethod().Name, Convert.ToInt32(hdfLoginCode.Value));
ShowMessage("Oops...", ex.Message, "error");
}
}
<asp:GridView ID="grdPlanning" class="table table-bordered" runat="server" OnRowDataBound="gr_RowDataBound"
onsorting="grdPlanning_Sorting" AllowSorting="True" OnRowCommand="grdPlanning_RowCommand" AutoGenerateColumns="true" DataKeyNames="BookID" >
Thanks