Click here to Skip to main content
15,910,981 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
I couldn't get the rowindex from the gridview in OnClick event... Can anyone help me ....

C#
protected void Abeyance_Click(Object sender, System.EventArgs e)
{
    int memoid = Convert.ToInt32(Session["MemoID"]);
    string description = TextBox3.Text;
    string priority = TextBox4.Text;
    DateTime dt2 = DateTime.ParseExact(TextBox5.Text, "d/M/yyyy", null);
    objMemoBAL.InsertToAbeyance("MemoAbeyance", memoid, description, priority, dt2, "Internal Memo",Session["Empcode"].ToString());
        
    HiddenField hdnMemoId = new HiddenField();
    LinkButton lnk = sender as LinkButton;
    
    GridViewRow gvrCurrent = ((LinkButton)lnk).NamingContainer as GridViewRow;
    hdnMemoId = (HiddenField)gvrCurrent.FindControl("hdnMemoId");
    int id = Convert.ToInt32(gvList.DataKeyNames[gvrCurrent.RowIndex]);
            
    gvList.DeleteRow(id);
            
    Response.Redirect("frmInternalMemo.aspx");
}// Abeyance and Defer
Posted
Updated 31-Mar-14 22:08pm
v3

 
Share this answer
 
GridViewRow gvrow = (GridViewRow)((LinkButton)e.CommandSource).NamingContainer;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900