Click here to Skip to main content
15,886,815 members
Please Sign up or sign in to vote.
2.60/5 (2 votes)
See more:
I have two Link buttons in GridView Approve and Reject I want Approve linkButton to be disabled when i click on it. I tried the following code but its not working.

C#
protected void gvManagerTimeSheet_RowCommand(object sender, GridViewCommandEventArgs e)

{

        if (e.CommandName == "ApproveRow")
        {
            GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
            LinkButton lnkbtn = (LinkButton)row.FindControl("lbApprove");
            lnkbtn.Enabled = false;

            int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
            int TimeSheetId = Convert.ToInt32(e.CommandArgument);

            string CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;

            using (SqlConnection con = new SqlConnection(CS))
            {
                SqlCommand cmd = new SqlCommand("spApproveTimeSheet ", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@TimeSheetId", TimeSheetId);

                con.Open();
                cmd.ExecuteNonQuery();

                GetManagerTimeSheets();
            }

        }
Posted

1 solution

Hi,
Do This


C#
LinkButton lnkBt = (LinkButton)e.CommandSource;
lnkBt.Enabled = false;
 
Share this answer
 
Comments
Member 11070376 19-Sep-14 11:46am    
Thanks... This code works fine if only these two lines are present in if condition

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