Forum Discussion

Anoop Mathur's avatar
Anoop Mathur
Copper Contributor
Jan 12, 2024

The LinkButton in Nested GridView is not responding to any event. How to solve this

Why "lnkUpdate" Button is not Responding to any event. Kindly Help. could not get solution anywhere

 

 

 

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace dmr.Employee
{
    public partial class Reporting_Officer_Performance_Appraisal : System.Web.UI.Page
    {
        string user_id = "";
        Label lblemployeeid;
        public bool rowCommandEventExecuted = false;
        int rowIndex = 0;

        protected void Page_Init(object sender, EventArgs e)
        {
            //if (!Page.IsPostBack)
            //{
                _BindService();
            //  }
        }




        protected void Page_Load(object sender, EventArgs e)
        {
            Page.ClientScript.GetPostBackEventReference(this, string.Empty);
            bool val1 = (System.Web.HttpContext.Current.User != null) && System.Web.HttpContext.Current.User.Identity.IsAuthenticated;

            if (val1 == true)
            {
                user_id = HttpContext.Current.User.Identity.Name;
                if (user_id == Convert.ToString(Session["userid"]) && Convert.ToInt32(Session["roleid"]) == 2)
                {
                    ValidationSettings.UnobtrusiveValidationMode = UnobtrusiveValidationMode.None;

                    if (!Page.IsPostBack)
                    {
                        _BindService();
                    }


                }
                else
                {
                    try
                    {
                        Session.Abandon();
                        FormsAuthentication.SignOut();
                        Response.Cache.SetCacheability(HttpCacheability.NoCache);
                        Response.Buffer = true;
                        Response.ExpiresAbsolute = DateTime.Now.AddDays(-1d);
                        Response.Expires = -1000;
                        Response.CacheControl = "no-cache";
                    }
                    catch (Exception ex2)
                    {
                        //  ExceptionLogging.SendErrorToText(ex2);
                        exception_label.Text = "Some Technical Error occurred,Please visit after some time";
                    }
                    Response.Redirect("../Login.aspx");



                }
            }
            else
            {
                Response.Redirect("../Login.aspx");
            }
        }


        public static void MakeAccessible(GridView grid)
        {
            if (grid.Rows.Count <= 0) return;
            grid.UseAccessibleHeader = true;
            grid.HeaderRow.TableSection = TableRowSection.TableHeader;
            if (grid.ShowFooter)
                grid.FooterRow.TableSection = TableRowSection.TableFooter;
        }

        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            MakeAccessible(employee_filled_performance_appraisal);
            //GridView childgrid = (GridView)employee_filled_performance_appraisal.FindControl("reporting_officer_fill_details");
            //MakeAccessible(childgrid);
        }



        private void _BindService()
        {

            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dmrConnectionString"].ToString());


            try
            {
                con.Open();
                SqlDataAdapter da = new SqlDataAdapter("sp_select_all_employee_details_performance_appraisal", con);

                // Create a DataSet or DataTable to hold the retrieved data
                //DataSet dataSet = new DataSet();
                DataTable dataTable = new DataTable();

                da.Fill(dataTable);

                
                    employee_filled_performance_appraisal.DataSource = dataTable;
                    employee_filled_performance_appraisal.DataBind();
                
                con.Close();
                //    employee_filled_performance_appraisal.DataBind();
                //if (rowCommandEventExecuted == true)
                //{

                //    GridViewRow row = employee_filled_performance_appraisal.Rows[rowIndex];


                //    Button lnkeditbtn = row.FindControl("lnkEdit") as Button;
                //    lnkeditbtn.Visible = false;


                //    using (SqlCommand command = new SqlCommand("sp_select_all_reporting_manager_details_performance_appraisal", con))
                //    {
                //        command.CommandType = CommandType.StoredProcedure;

                //        // Add parameters to the stored procedure
                //        command.Parameters.AddWithValue("@employeeid", lblemployeeid.Text); // Replace with your parameter name and value

                //        // Create a SqlDataAdapter
                //        SqlDataAdapter adapter = new SqlDataAdapter(command);


                //        da.Fill(dataTable);


                //        // Use the DataAdapter to fill the DataSet or DataTable
                //        //// adapter.Fill(dataSet); // or
                //        //adapter.Fill(dt1);

                //        // da.Fill(dataTable);

                //        // if (Convert.ToInt32(dt1.Rows.Count) > 0)
                //        // {

                //        //dt1.Merge(dataTable);

                //        // }



                //    }
                //}
                //else
                //{



                //    //    Label lblinconsistency1 = (Label)employee_filled_performance_appraisal.FindControl("lblinconsistency") as Label;
                //    //    if (lblinconsistency1 != null)
                //    //    {
                //    //        lblinconsistency1.Visible = false;
                //    //    }
                //}



                //if (Convert.ToInt32(dt1.Rows.Count)>0)
                //{
                //    employee_filled_performance_appraisal.DataSource = dt1;
                //   employee_filled_performance_appraisal.DataBind();
                //}
                //else if (Convert.ToInt32(dataTable.Rows.Count)>0)
                //{
                //    employee_filled_performance_appraisal.DataSource = dataTable;
                //    employee_filled_performance_appraisal.DataBind();
                //}




            }
            catch (Exception ex)
            {
                //ExceptionLogging.SendErrorToText(ex);
                // Exception_Details.Text = ex.ToString();
            }
            //finally
            //{
            //    con.Dispose(); // And this will also close the connection
            //}







        }







        protected void employee_filled_performance_appraisal_RowEditing(object sender, GridViewEditEventArgs e)
        {

           
                SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dmrConnectionString"].ToString());
                try
                {
                //if (Page.IsPostBack)
                //{
                //   GridView g2 = (GridView)sender;
                //g2.EditIndex = e.NewEditIndex;
                //  employee_filled_performance_appraisal.EditIndex = e.NewEditIndex;
                //employee_filled_performance_appraisal.UseAccessibleHeader = true;
                //    employee_filled_performance_appraisal.HeaderRow.TableSection = TableRowSection.TableHeader;
               
                    GridViewRow row = employee_filled_performance_appraisal.Rows[e.NewEditIndex];
                //  GridViewRow ParentGridRow = employee_filled_performance_appraisal.Rows[e.NewEditIndex];
                row.BackColor = System.Drawing.Color.Snow;
                var val = row.RowIndex;
                GridView GridViewChild = (GridView)row.FindControl("reporting_officer_fill_details");
              
                GridViewChild.EditIndex = 0;
                GridViewChild.SelectedIndex = e.NewEditIndex;



                //lnkupd.Click += new EventHandler(reporting_officer_fill_details_RowUpdating(object sender, GridViewUpdateEventArgs e));
                //GridViewChild.SetEditRow(row.RowIndex);
                GridViewChild.EditRowStyle.BackColor = System.Drawing.Color.LightBlue;
               //GridViewChild.UseAccessibleHeader = true;
                        //GridViewChild.HeaderRow.TableSection = TableRowSection.TableHeader;




                    con.Open();





                    DataSet dts = new DataSet();



                    SqlCommand command = new SqlCommand("sp_select_all_reporting_manager_details_performance_appraisal", con);

                    command.CommandType = CommandType.StoredProcedure;

                    // Add parameters to the stored procedure
                    command.Parameters.AddWithValue("@employeeid", lblemployeeid.Text); // Replace with your parameter name and value

                    // Create a SqlDataAdapter
                    SqlDataAdapter adapter = new SqlDataAdapter(command);



                    // Create a DataSet or DataTable to hold the retrieved data
                    //  D//ataTable dataSet = new DataSet();

                    // Use the DataAdapter to fill the DataSet or DataTable
                    // adapter.Fill(dataSet); // or
                    adapter.Fill(dts);

                    SqlDataAdapter da = new SqlDataAdapter("sp_select_all_employee_details_performance_appraisal", con);


                    // DataSet dataTable = new DataTable();

                    //      da.Fill(dataTable);
                    //   dt1.Merge(dataTable);
                   

                    GridViewChild.DataSource = dts;

                    //if ((!dts.HasErrors) && (Convert.ToInt32(dts.Tables[0].Rows) > 0) )
                    //{
                    if (IsPostBack)
                    {
               
                    GridViewChild.DataBind();
                
                }
                    //}

                    //_BindService();

                    //    Button btnedit = row.FindControl("lnkEdit") as Button;
                    //     btnedit.Visible = false;

                    //da.Fill(dataTable);

                    //if (Convert.ToInt32(dt1.Rows.Count) > 0)
                    //{



                    //}

                    con.Close();



                    //   }



                }
                catch (Exception ex)
                {
                    //ExceptionLogging.SendErrorToText(ex);
                    // Exception_Details.Text = ex.ToString();
                }
                finally
                {
                    //con.Dispose(); // And this will also close the connection
                }

            }
        

        protected void employee_filled_performance_appraisal_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow && employee_filled_performance_appraisal.EditIndex == e.Row.RowIndex)
            {
                if (rowCommandEventExecuted == true)
                {
                    GridViewRow row = e.Row;
                    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dmrConnectionString"].ToString());
                    con.Open();

                    //GridView childgridview = (GridView)e.Row.FindControl("reporting_officer_fill_details");

                    //    GridView GridViewChild = (GridView)maingridview.FindControl("reporting_officer_fill_details");
                    SqlCommand command = new SqlCommand("sp_select_all_reporting_manager_details_performance_appraisal", con);
                    command.CommandType = CommandType.StoredProcedure;

                    //    // Add parameters to the stored procedure
                    command.Parameters.AddWithValue("@employeeid", lblemployeeid.Text); // Replace with your parameter name and value

                    //    // Create a SqlDataAdapter
                    SqlDataAdapter adapter = new SqlDataAdapter(command);

                    //    // Create a DataSet or DataTable to hold the retrieved data
                    DataSet dtchild = new DataSet();

                    adapter.Fill(dtchild);

                    SqlDataAdapter da = new SqlDataAdapter("sp_select_all_employee_details_performance_appraisal", con);


                    //    DataTable dataTable = new DataTable();

                    GridView gv = new GridView();
                    gv = (GridView)row.FindControl("reporting_officer_fill_details");

                   
                        gv.DataSource = dtchild;
                    if (IsPostBack)
                    {
                        gv.DataBind();
                    }



                    con.Close();
                }
            }
        }


        //if (e.Row.RowType == DataControlRowType.DataRow)
        //{
        //    LinkButton lnkUpdate = (LinkButton)e.Row.FindControl("lnkUpdate");
        //    if (lnkUpdate != null)
        //    {
        //        int rowIndex = e.Row.RowIndex;
        //        lnkUpdate.ID = "lnkUpdate_" + rowIndex; // Set the ID with the row index
        //    }
        //}

        //if (e.Row.RowType == DataControlRowType.DataRow && employee_filled_performance_appraisal.EditIndex == -1)
        //{
        //    e.Row.Cells[0].Attributes.Add("style", "word-break:break-all;word-wrap:break-word;");

        //    //    employee_filled_performance_appraisal.EditIndex = 0;

        //    // You might need to rebind your data after setting the EditIndex
        //if (!Page.IsPostBack)
        //{
        //    _BindService();
        //}

        //}

        protected void employee_filled_performance_appraisal_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Edit")
            {
                rowCommandEventExecuted = true;
                rowIndex = Convert.ToInt32(e.CommandArgument.ToString());

                GridViewRow row = employee_filled_performance_appraisal.Rows[rowIndex];

                lblemployeeid = row.FindControl("lblemployeeid") as Label;





            }

            if (e.CommandName == "reportingUpdate")
            {


            }


        }


        protected void employee_filled_performance_appraisal_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        {



        }

        protected void employee_filled_performance_appraisal_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            
        }

        protected void reporting_officer_fill_details_RowEditing(object sender, GridViewEditEventArgs e)
        {
            //employee_filled_performance_appraisal.EditIndex = e.NewEditIndex;
            //employee_filled_performance_appraisal.UseAccessibleHeader = true;
            //    employee_filled_performance_appraisal.HeaderRow.TableSection = TableRowSection.TableHeader;

            GridViewRow row = employee_filled_performance_appraisal.Rows[e.NewEditIndex];
            //  GridViewRow ParentGridRow = employee_filled_performance_appraisal.Rows[e.NewEditIndex];

            GridView GridViewChild = (GridView)row.FindControl("reporting_officer_fill_details");
           GridViewChild.EditIndex = 0;
        //    GridViewChild.UseAccessibleHeader = true;

            //if (!Page.IsPostBack)
            //{


            //GridViewRow row = employee_filled_performance_appraisal.Rows[e.NewEditIndex];



                DataTable dt1 = new DataTable();

                SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dmrConnectionString"].ToString());
                con.Open();

                using (SqlCommand command = new SqlCommand("sp_select_all_reporting_manager_details_performance_appraisal", con))
                {
                    command.CommandType = CommandType.StoredProcedure;

                    // Add parameters to the stored procedure
                    command.Parameters.AddWithValue("@employeeid", lblemployeeid.Text); // Replace with your parameter name and value

                    // Create a SqlDataAdapter
                    SqlDataAdapter adapter = new SqlDataAdapter(command);





                    // Use the DataAdapter to fill the DataSet or DataTable
                    // adapter.Fill(dataSet); // or
                    adapter.Fill(dt1);

                    SqlDataAdapter da = new SqlDataAdapter("sp_select_all_employee_details_performance_appraisal", con);

                    // Create a DataSet or DataTable to hold the retrieved data
                    //DataSet dataSet = new DataSet();
                    DataTable dataTable = new DataTable();

                      //  da.Fill(dataTable);
                      //dt1.Merge(dataTable);

                    GridViewChild.DataSource = dt1;
               GridViewChild.DataBind();
               

                    //  Button btnedit = row.FindControl("lnkEdit") as Button;
                    //     btnedit.Visible = false;

                    //da.Fill(dataTable);

                    //if (Convert.ToInt32(dt1.Rows.Count) > 0)
                    //{



                    //}

                    con.Close();

                }

          //  }


        }

        protected void reporting_officer_fill_details_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        {
            //employee_filled_performance_appraisal.EditIndex = e.RowIndex;
            GridViewRow ParentGridRow = employee_filled_performance_appraisal.Rows[e.RowIndex];
            GridView GridViewChild = (GridView)ParentGridRow.FindControl("reporting_officer_fill_details");
            GridViewChild.EditIndex = -1;
            GridViewChild.UseAccessibleHeader = true;
            //GridViewChild.HeaderRow.TableSection = TableRowSection.TableHeader;

            //if (Page.IsPostBack)
            //{
                _BindService();
           // }

            //GridViewRow row = employee_filled_performance_appraisal.Rows[e.RowIndex];
            //Button btnedit = row.FindControl("lnkEdit") as Button;
            //btnedit.Visible = true;
        }

        protected void reporting_officer_fill_details_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dmrConnectionString"].ToString());
            con.Open();
            try
            {
                var id = employee_filled_performance_appraisal.DataKeys[e.RowIndex].Value;
                GridViewRow row = employee_filled_performance_appraisal.Rows[e.RowIndex];
                GridView GridViewChild = (GridView)row.FindControl("reporting_officer_fill_details");
                TextBox inconsistency_self_appr = GridViewChild.FindControl("txt_inconsistency_self_appraisal") as TextBox;

                //    GridViewRow row = gridService.Rows[e.RowIndex] as GridViewRow;
                //    Label tdisablestatus = row.FindControl("lbldisablestatus") as Label;
                //    DropDownList ttitle = row.FindControl("ddl_title") as DropDownList;
                //    DropDownList tprepaidfees = row.FindControl("ddlprepaid_feesapplicable") as DropDownList;
                //    DropDownList tqrid = row.FindControl("ddlqr_id") as DropDownList;
                //    DropDownList tfeestype = row.FindControl("ddlfees_type") as DropDownList;
                //    TextBox tfirstname = row.FindControl("txtfirst_name") as TextBox;
                //    TextBox tmiddlename = row.FindControl("txtmiddle_name") as TextBox;
                //    TextBox tlastname = row.FindControl("txtlast_name") as TextBox;
                //    TextBox tdateofbirth = row.FindControl("txt_dateofbirth") as TextBox;
                //    TextBox temail = row.FindControl("txt_email") as TextBox;
                //    TextBox tdesignation = row.FindControl("txt_designation") as TextBox;
                //    TextBox torganize = row.FindControl("txt_organize") as TextBox;
                //    TextBox taddress = row.FindControl("txt_address") as TextBox;
                //    TextBox tpostal = row.FindControl("txt_postal") as TextBox;
                //    TextBox tcity = row.FindControl("txt_city") as TextBox;
                //    TextBox tstate = row.FindControl("txt_state") as TextBox;

                //    TextBox tpassportno = row.FindControl("txt_passportno") as TextBox;
                //    TextBox tplaceofissue = row.FindControl("txt_placeofissue") as TextBox;
                //    TextBox tdateofissue = row.FindControl("txt_dateofissue") as TextBox;
                //    TextBox tdateofexpiry = row.FindControl("txt_dateofexpiry") as TextBox;
                //    DropDownList ddlcountry2 = row.FindControl("ddlcountry1") as DropDownList;
                //    TextBox tcountry = row.FindControl("txtcountry1") as TextBox;
                //    TextBox tmobile = row.FindControl("txt_mobile") as TextBox;
                //    Label tcreatedate = row.FindControl("lblcreatedate") as Label;
                //    TextBox tpassword = row.FindControl("txt_password") as TextBox;
                //    SqlConnection con1 = new SqlConnection(ConfigurationManager.ConnectionStrings["icoldConnectionString"].ToString());
                //    String updatedby = "Admin";
                //    con1.Open();
                //    SqlCommand cmdupdate = new SqlCommand("sp_updateuser", con1);
                //    cmdupdate.CommandType = CommandType.StoredProcedure;
                //    cmdupdate.Parameters.AddWithValue("@id", id);
                //    cmdupdate.Parameters.AddWithValue("@prepaidfees", tprepaidfees.SelectedItem.Value);
                //    cmdupdate.Parameters.AddWithValue("@feestype", tfeestype.SelectedItem.Value);
                //    cmdupdate.Parameters.AddWithValue("@qrid", tqrid.SelectedItem.Value);
                //    cmdupdate.Parameters.AddWithValue("@disable_status", tdisablestatus.Text);
                //    cmdupdate.Parameters.AddWithValue("@title", ttitle.SelectedItem.Value);
                //    cmdupdate.Parameters.AddWithValue("@first_name", tfirstname.Text);
                //    cmdupdate.Parameters.AddWithValue("@middle_name", tmiddlename.Text);
                //    cmdupdate.Parameters.AddWithValue("@last_name", tlastname.Text);
                //    CultureInfo provider = CultureInfo.InvariantCulture;
                //    cmdupdate.Parameters.AddWithValue("@dateofbirth", System.Convert.ToDateTime(tdateofbirth.Text));
                //    //cmdupdate.Parameters.AddWithValue("@dateofbirth", System.Convert.ToDateTime(tdateofbirth.Text));

                //    SqlCommand cmd = new SqlCommand("sp_pass", con1);
                //    cmd.CommandType = CommandType.StoredProcedure;
                //    cmd.Parameters.AddWithValue("@id", id);
                //    SqlParameter RetParam1 = new SqlParameter("ReturnValue", DbType.Int32);
                //    SqlParameter outparam = new SqlParameter("@passdatabase", SqlDbType.NVarChar, 500);
                //    SqlParameter outparam1 = new SqlParameter("@user_id", SqlDbType.NVarChar, 125);
                //    RetParam1.Direction = ParameterDirection.ReturnValue;
                //    outparam.Direction = ParameterDirection.Output;
                //    outparam1.Direction = ParameterDirection.Output;
                //    cmd.Parameters.Add(RetParam1);
                //    cmd.Parameters.Add(outparam);
                //    cmd.Parameters.Add(outparam1);
                //    cmd.ExecuteNonQuery();
                //    string passval = Convert.ToString(cmd.Parameters["@passdatabase"].Value);
                //    string useridval = Convert.ToString(cmd.Parameters["@user_id"].Value);
                //    cmdupdate.Parameters.AddWithValue("@user_id", useridval);
                //    cmdupdate.Parameters.AddWithValue("@password", passval);
                //    cmdupdate.Parameters.AddWithValue("@passportno", tpassportno.Text);
                //    cmdupdate.Parameters.AddWithValue("@placeofissue", tplaceofissue.Text);
                //    cmdupdate.Parameters.AddWithValue("@dateofissue", System.Convert.ToDateTime(tdateofissue.Text));
                //    cmdupdate.Parameters.AddWithValue("@dateofexpiry", System.Convert.ToDateTime(tdateofexpiry.Text));
                //    cmdupdate.Parameters.AddWithValue("@email", temail.Text);
                //    cmdupdate.Parameters.AddWithValue("@designation", tdesignation.Text);
                //    cmdupdate.Parameters.AddWithValue("@organization", torganize.Text);
                //    cmdupdate.Parameters.AddWithValue("@address", taddress.Text);
                //    cmdupdate.Parameters.AddWithValue("@postalcode", tpostal.Text);
                //    cmdupdate.Parameters.AddWithValue("@city", tcity.Text);
                //    cmdupdate.Parameters.AddWithValue("@state", tstate.Text);

                //    if (ddlcountry2.SelectedItem.Value == "103")
                //    {
                //        cmdupdate.Parameters.AddWithValue("@country_non_icold", tcountry.Text);
                //        cmdupdate.Parameters.AddWithValue("@country", ddlcountry2.SelectedItem.Value);
                //    }
                //    else
                //    {

                //        cmdupdate.Parameters.AddWithValue("@country", ddlcountry2.SelectedItem.Value);
                //        cmdupdate.Parameters.AddWithValue("@country_non_icold", "");
                //    }
                //    cmdupdate.Parameters.AddWithValue("@mobile", tmobile.Text);
                //    cmdupdate.Parameters.AddWithValue("@create_date", System.Convert.ToDateTime(tcreatedate.Text));
                //    cmdupdate.Parameters.AddWithValue("@updated_by", updatedby);
                //    SqlParameter RetParam = new SqlParameter("ReturnValue", DbType.Int32);
                //    RetParam.Direction = ParameterDirection.ReturnValue;
                //    cmdupdate.Parameters.Add(RetParam);
                //    cmdupdate.ExecuteNonQuery();
                //    con1.Close();
                //    int IntReturn = Convert.ToInt32(cmdupdate.Parameters["ReturnValue"].Value);

                //    gridService.EditIndex = -1;

                //    _BindService();

                //    if (IntReturn == 1)
                //    {
                //        ScriptManager.RegisterStartupScript(this, this.GetType(), "myalertupdateed", "javascript&colon;alert('" + "User Updated Successfully" + "');", true);

                //    }
                //    else if (IntReturn == -1)
                //    {
                //        ScriptManager.RegisterStartupScript(this, this.GetType(), "myalertupdatenotexist", "javascript&colon;alert('" + "User Does not Exist" + "');", true);
                //    }
                //    else if (IntReturn == -2)
                //    {
                //        ScriptManager.RegisterStartupScript(this, this.GetType(), "myalertupdatenotexist", "javascript&colon;alert('" + "qr id is already assigned to other user" + "');", true);
                //    }
                //}
                //catch (Exception ex)
                //{
                //    ExceptionLogging.SendErrorToText(ex);
                //    exception_label.Text = "Some Technical Error occurred,Please visit after some time";
            }
            catch (Exception ex)
            {
                //ExceptionLogging.SendErrorToText(ex);
                // Exception_Details.Text = ex.ToString();
            }





            con.Close();
        }

        //protected void reporting_officer_fill_details_RowDataBound(object sender, GridViewRowEventArgs e)
        //{
        //    if (e.Row.RowType == DataControlRowType.DataRow)
        //    {
        //        if (rowCommandEventExecuted == true)
        //        {
        //            GridViewRow row = e.Row;
        //            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dmrConnectionString"].ToString());
        //            con.Open();

        //            //GridView childgridview = (GridView)e.Row.FindControl("reporting_officer_fill_details");

        //            //    GridView GridViewChild = (GridView)maingridview.FindControl("reporting_officer_fill_details");
        //            SqlCommand command = new SqlCommand("sp_select_all_reporting_manager_details_performance_appraisal", con);
        //            command.CommandType = CommandType.StoredProcedure;

        //            //    // Add parameters to the stored procedure
        //            command.Parameters.AddWithValue("@employeeid", lblemployeeid.Text); // Replace with your parameter name and value

        //            //    // Create a SqlDataAdapter
        //            SqlDataAdapter adapter = new SqlDataAdapter(command);

        //            //    // Create a DataSet or DataTable to hold the retrieved data
        //            DataSet dtchild = new DataSet();

        //            adapter.Fill(dtchild);

        //            SqlDataAdapter da = new SqlDataAdapter("sp_select_all_employee_details_performance_appraisal", con);


        //            //    DataTable dataTable = new DataTable();

        //            GridViewRow ParentGridRow = employee_filled_performance_appraisal.Rows[e.Row.RowIndex];
        //            GridView GridViewChild = (GridView)ParentGridRow.FindControl("reporting_officer_fill_details");
        //            GridViewChild.EditIndex = e.Row.RowIndex;
        //            GridViewChild.UseAccessibleHeader = true;
        //            //GridViewChild.HeaderRow.TableSection = TableRowSection.TableHeader;


        //           // GridViewChild.DataSource = dtchild;
        //           //GridViewChild.DataBind();




        //            con.Close();
        //        }
        //    }
        //}

        protected void reporting_officer_fill_details_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "reportingUpdate")
            {


            }
        }

        protected void employee_filled_performance_appraisal_RowCreated(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                GridView reportingofficerfilldetails = e.Row.FindControl("reporting_officer_fill_details") as GridView;
                reportingofficerfilldetails.EditIndex = 0;
                reportingofficerfilldetails.RowCommand += new GridViewCommandEventHandler(reporting_officer_fill_details_RowCommand);
            }
        }
    }
}

<%@ Page Title="" Language="C#" MasterPageFile="~/Employee/emp.Master" AutoEventWireup="true" ValidateRequest="true" ViewStateMode="Enabled" CodeBehind="Reporting_Officer_Performance_Appraisal.aspx.cs" Inherits="dmr.Employee.Reporting_Officer_Performance_Appraisal" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .WordWrap {
            word-break: break-all;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <section class="container">
        <form id="form1" method="post" enctype="multipart/form-data" runat="server">
            <asp:ScriptManager ID="sm1" runat="server" />
            <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" ClientIDMode="Static" runat="server">
                <ContentTemplate>
                    <div class="container" style="overflow-x: auto; width: 100%; max-height: 600px;">
                        <asp:Label ID="exception_label" runat="server" Text=""></asp:Label>
                    <section runat="server" class="display_section container">
                            <asp:GridView ID="employee_filled_performance_appraisal" Caption="DMR Filled Employee Performance Appraisal Details" GridLines="None" Font-Names="Century Gothic" CellPadding="10" CellSpacing="10" RowStyle-Width="100%" DataKeyNames="id" AutoGenerateColumns="False" AllowPaging="True" ClientIDMode="Static" CssClass="WordWrap" Height="100%" Width="100%" ForeColor="#333333" HorizontalAlign="Justify" PageSize="20" runat="server" OnRowEditing="employee_filled_performance_appraisal_RowEditing" OnRowDataBound="employee_filled_performance_appraisal_RowDataBound" OnRowCommand="employee_filled_performance_appraisal_RowCommand" OnRowCancelingEdit="employee_filled_performance_appraisal_RowCancelingEdit" OnRowUpdating="employee_filled_performance_appraisal_RowUpdating" OnRowCreated="employee_filled_performance_appraisal_RowCreated" >
                                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                                <Columns>
                                    <asp:TemplateField ControlStyle-Width="100px" HeaderStyle-Width="100px" HeaderText="Edit">
                                        <ItemTemplate>
                                              <asp:LinkButton ID="lnkEdit" ClientIDMode="Static" CommandArgument='<%#  ((GridViewRow)Container).RowIndex.ToString()%>' CausesValidation="false"  runat="server" Text="Edit" CommandName="Edit" />
                                

                                        </ItemTemplate>

                                    </asp:TemplateField>
                                    

                                    <asp:TemplateField HeaderStyle-Wrap="false" HeaderText="Reporting Officer">
                                        
                                        <ItemTemplate>
                                             
                                            <asp:GridView ID="reporting_officer_fill_details"  ClientIDMode="Static" Caption="Reporting Officer Details" GridLines="None" Font-Names="Century Gothic" CellPadding="10" CellSpacing="10" RowStyle-Width="100%"  AutoGenerateColumns="False" AllowPaging="True"  CssClass="WordWrap" Height="100%" Width="100%" ForeColor="#333333" HorizontalAlign="Justify" PageSize="20" runat="server" OnRowEditing="reporting_officer_fill_details_RowEditing" OnRowCancelingEdit="reporting_officer_fill_details_RowCancelingEdit"  OnRowUpdating="reporting_officer_fill_details_RowUpdating" OnRowCommand="reporting_officer_fill_details_RowCommand"   >
                                                    <Columns>
                                                        <asp:TemplateField HeaderStyle-Wrap="false" ControlStyle-Width="100px" HeaderStyle-Width="100px" HeaderText="Enter Details">
                                                            <ItemTemplate>
                                                                <asp:LinkButton ID="lnkUpdate" ClientIDMode="Static" CausesValidation="True" CommandName="reportingUpdate" runat="server">Update</asp:LinkButton>
                                                            <asp:LinkButton ID="lnkCancel"  CausesValidation="True" ValidationGroup="updatereportingofficer" runat="server" Text="Cancel" CommandName="Cancel"  />
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                
                                                    <asp:TemplateField HeaderStyle-Wrap="false" HeaderText="Inconsistency in Self Appraisal">
                                                        <ItemTemplate>

                                                        </ItemTemplate>

                                                        <EditItemTemplate>
                                                                  <asp:Label ID="lblinconsistency" ClientIDMode="Static" runat="server" Text='<%#  Eval("Inconsistency_Self_Appraisal") %>'></asp:Label>
         
                                                            
                                                            <asp:TextBox ID="txt_inconsistency_self_appraisal" ValidationGroup="updatereportingofficer" TextMode="MultiLine" MaxLength="300" ClientIDMode="Static" runat="server" Text=' '></asp:TextBox>



                                                        </EditItemTemplate>
                                                    </asp:TemplateField>


                                                    <asp:TemplateField HeaderStyle-Wrap="false" HeaderText="Communication Skills Rating">
                                                        <ItemTemplate>

                                                        </ItemTemplate>
                                                        <EditItemTemplate>

                                                       <asp:Label ID="lblcommunicationskillsrating" ClientIDMode="Static" runat="server" Text='<%#  Eval("Communication_Skills") %>'></asp:Label>

                                                            <span style="color: red; height: 30px">(Rate of 1 to 5 Excellent-5 , Poor-0)</span>

                                                        

                                                            <asp:RadioButtonList ID="rblcommskillrating" ValidationGroup="updatereportingofficer" RepeatDirection="Horizontal" runat="server">
                                                                <asp:ListItem Text="1" Value="1"></asp:ListItem>
                                                                <asp:ListItem Text="2" Value="2"></asp:ListItem>
                                                                <asp:ListItem Text="3" Value="3"></asp:ListItem>
                                                                <asp:ListItem Text="4" Value="4"></asp:ListItem>
                                                                <asp:ListItem Text="5" Value="5"></asp:ListItem>
                                                            </asp:RadioButtonList>
                                                        </EditItemTemplate>
                                                    </asp:TemplateField>

                                                    <asp:TemplateField HeaderStyle-Wrap="false" HeaderText="Job Knowledge">

                                                        <EditItemTemplate>

                                                            <span style="color: red; height: 30px">(Rate of 1 to 5 Excellent-5 , Poor-0)</span>

                                                            <asp:Label ID="lbljobknowledge" ClientIDMode="Static" runat="server" Text='<%# rowCommandEventExecuted == true ? Eval("Job_Knowledge") : ""%>'></asp:Label>


                                                            <asp:RadioButtonList ID="rbljobknowledge" ValidationGroup="updatereportingofficer" RepeatDirection="Horizontal" runat="server">
                                                                <asp:ListItem Text="1" Value="1"></asp:ListItem>
                                                                <asp:ListItem Text="2" Value="2"></asp:ListItem>
                                                                <asp:ListItem Text="3" Value="3"></asp:ListItem>
                                                                <asp:ListItem Text="4" Value="4"></asp:ListItem>
                                                                <asp:ListItem Text="5" Value="5"></asp:ListItem>
                                                            </asp:RadioButtonList>
                                                        </EditItemTemplate>
                                                    </asp:TemplateField>

                                                    <asp:TemplateField HeaderStyle-Wrap="false" HeaderText="Problem Solving Skills">

                                                        <EditItemTemplate>

                                                            <span style="color: red; height: 30px">(Rate of 1 to 5 Excellent-5 , Poor-0)</span>

                                                            <asp:Label ID="lblproblemsolvingskills" ClientIDMode="Static" runat="server" Text='<%# rowCommandEventExecuted == true ? Eval("Problem_Solving_Skills") : ""%>'></asp:Label>


                                                            <asp:RadioButtonList ID="rblproblemsolvingsills" ValidationGroup="updatereportingofficer" RepeatDirection="Horizontal" runat="server">
                                                                <asp:ListItem Text="1" Value="1"></asp:ListItem>
                                                                <asp:ListItem Text="2" Value="2"></asp:ListItem>
                                                                <asp:ListItem Text="3" Value="3"></asp:ListItem>
                                                                <asp:ListItem Text="4" Value="4"></asp:ListItem>
                                                                <asp:ListItem Text="5" Value="5"></asp:ListItem>
                                                            </asp:RadioButtonList>
                                                        </EditItemTemplate>
                                                    </asp:TemplateField>


                                                    <asp:TemplateField HeaderStyle-Wrap="false" HeaderText="Initiative">

                                                        <EditItemTemplate>

                                                            <span style="color: red; height: 30px">(Rate of 1 to 5 Excellent-5 , Poor-0)</span>

                                                            <asp:Label ID="lblinitiative" ClientIDMode="Static" runat="server" Text='<%# rowCommandEventExecuted == true ? Eval("Initiative") : ""%>'></asp:Label>


                                                            <asp:RadioButtonList ID="rblinitiative" ValidationGroup="updatereportingofficer" RepeatDirection="Horizontal" runat="server">
                                                                <asp:ListItem Text="1" Value="1"></asp:ListItem>
                                                                <asp:ListItem Text="2" Value="2"></asp:ListItem>
                                                                <asp:ListItem Text="3" Value="3"></asp:ListItem>
                                                                <asp:ListItem Text="4" Value="4"></asp:ListItem>
                                                                <asp:ListItem Text="5" Value="5"></asp:ListItem>
                                                            </asp:RadioButtonList>
                                                        </EditItemTemplate>
                                                    </asp:TemplateField>


                                                    <asp:TemplateField HeaderStyle-Wrap="false" HeaderText="Team Work">

                                                        <EditItemTemplate>

                                                            <span style="color: red; height: 30px">(Rate of 1 to 5 Excellent-5 , Poor-0)</span>

                                                            <asp:Label ID="lblteamwork" ClientIDMode="Static" runat="server" Text='<%# rowCommandEventExecuted == true ? Eval("Teamwork") : ""%>'></asp:Label>


                                                            <asp:RadioButtonList ID="rblteamwork" ValidationGroup="updatereportingofficer" RepeatDirection="Horizontal" runat="server">
                                                                <asp:ListItem Text="1" Value="1"></asp:ListItem>
                                                                <asp:ListItem Text="2" Value="2"></asp:ListItem>
                                                                <asp:ListItem Text="3" Value="3"></asp:ListItem>
                                                                <asp:ListItem Text="4" Value="4"></asp:ListItem>
                                                                <asp:ListItem Text="5" Value="5"></asp:ListItem>
                                                            </asp:RadioButtonList>
                                                        </EditItemTemplate>
                                                    </asp:TemplateField>


                                                    <asp:TemplateField HeaderStyle-Wrap="false" HeaderText="Meeting Target Capacity">

                                                        <EditItemTemplate>

                                                            <span style="color: red; height: 30px">(Rate of 1 to 5 Excellent-5 , Poor-0)</span>

                                                            <asp:Label ID="lblmeetingtargetcapacity" ValidationGroup="updatereportingofficer" ClientIDMode="Static" runat="server" Text='<%# rowCommandEventExecuted == true ? Eval("Meeting_Targets_Capacity") : ""%>'></asp:Label>


                                                            <asp:RadioButtonList ID="rblmeetingtargetcapacity" RepeatDirection="Horizontal" runat="server">
                                                                <asp:ListItem Text="1" Value="1"></asp:ListItem>
                                                                <asp:ListItem Text="2" Value="2"></asp:ListItem>
                                                                <asp:ListItem Text="3" Value="3"></asp:ListItem>
                                                                <asp:ListItem Text="4" Value="4"></asp:ListItem>
                                                                <asp:ListItem Text="5" Value="5"></asp:ListItem>
                                                            </asp:RadioButtonList>
                                                        </EditItemTemplate>
                                                    </asp:TemplateField>


                                                    <asp:TemplateField HeaderStyle-Wrap="false" HeaderText="Significant Contribution">

                                                        <EditItemTemplate>



                                                            <asp:Label ID="lblsignificantcontribution" ClientIDMode="Static" runat="server" Text='<%# rowCommandEventExecuted == true ? Eval("Significant_Contribution") : ""%>'></asp:Label>

                                                            <asp:TextBox ID="txt_significant_contribution"  ValidationGroup="updatereportingofficer" TextMode="MultiLine" MaxLength="300" ClientIDMode="Static" runat="server" Text=' '></asp:TextBox>

                                                        </EditItemTemplate>
                                                    </asp:TemplateField>


                                                    <asp:TemplateField HeaderStyle-Wrap="false" HeaderText="Other Areas Potential">

                                                        <EditItemTemplate>



                                                            <asp:Label ID="lblotherareaspotential" ClientIDMode="Static" runat="server" Text='<%# rowCommandEventExecuted == true ? Eval("Other_Areas_Potential") : ""%>'></asp:Label>

                                                            <asp:TextBox ID="txt_other_areas_potential"  ValidationGroup="updatereportingofficer"  TextMode="MultiLine" MaxLength="300" ClientIDMode="Static" runat="server" Text=' '></asp:TextBox>

                                                        </EditItemTemplate>
                                                    </asp:TemplateField>

                                                    <asp:TemplateField HeaderStyle-Wrap="false" HeaderText="Overall Rating">

                                                        <EditItemTemplate>



                                                            <asp:Label ID="lbloverallrating"  ValidationGroup="updatereportingofficer"  ClientIDMode="Static" runat="server" Text='<%# rowCommandEventExecuted == true ? Eval("Meeting_Targets_Capacity") : ""%>'></asp:Label>

                                                            <asp:DropDownList ID="ddloverallrating" runat="server">
                                                                <asp:ListItem Text="Select Rating" Value=""></asp:ListItem>
                                                                <asp:ListItem Text="Excellent" Value="5"></asp:ListItem>
                                                                <asp:ListItem Text="Very Good" Value="4"></asp:ListItem>
                                                                <asp:ListItem Text="Good" Value="3"></asp:ListItem>
                                                                <asp:ListItem Text="Average" Value="2"></asp:ListItem>
                                                                <asp:ListItem Text="Poor" Value="1"></asp:ListItem>
                                                            </asp:DropDownList>

                                                        </EditItemTemplate>
                                                    </asp:TemplateField>
                                                </Columns>
                                    
                                          </asp:GridView>
                            
                                        </ItemTemplate>

                                        
                                    </asp:TemplateField>

                                    <asp:TemplateField Visible="true" HeaderStyle-Wrap="false" HeaderText="#">
                                        <ItemTemplate>
                                            <asp:Label ID="lblID" Visible="true" ClientIDMode="Static" runat="server" Text='<%# Eval("id") %>'>   </asp:Label>

                                            <itemstyle width="100px" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField Visible="true" HeaderStyle-Wrap="false" HeaderText="emptableid">
                                        <ItemTemplate>
                                            <asp:Label ID="lblemptableid" Visible="true" ClientIDMode="Static" runat="server"
                                                Text='<%#Eval("emptableid")%>'>
                                            </asp:Label>
                                        </ItemTemplate>
                                        <ItemStyle Width="100px" />
                                    </asp:TemplateField>
                                    <asp:TemplateField Visible="true" HeaderStyle-Wrap="false" HeaderText="Employee ID">
                                        <ItemTemplate>
                                            <asp:Label ID="lblemployeeid" Visible="true" ClientIDMode="Static" runat="server"
                                                Text='<%#Eval("Employee_ID")%>'>
                                            </asp:Label>
                                        </ItemTemplate>
                                        <ItemStyle Width="100px" />
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderStyle-Wrap="false" HeaderStyle-Width="300px" Visible="true" HeaderText="Name">
                                        <ItemTemplate>
                                            <asp:Label ID="lblemployeename" Visible="true" Width="300px" ClientIDMode="Static" runat="server"
                                                Text='<%#Eval("Employee_Name")%>'>
                                            </asp:Label>
                                        </ItemTemplate>
                                        <ItemStyle Wrap="True" />
                                    </asp:TemplateField>
                                    <asp:TemplateField Visible="true" HeaderStyle-Wrap="false" HeaderText="Period of Appraisal">
                                        <ItemTemplate>
                                            <asp:Label ID="lblappraisalperiod" Visible="true" ClientIDMode="Static" runat="server"
                                                Text='<%#Eval("Period_of_Appraisal")%>'>
                                            </asp:Label>
                                        </ItemTemplate>
                                        <ItemStyle Wrap="True" />
                                    </asp:TemplateField>
                                    <asp:TemplateField Visible="true" HeaderStyle-Wrap="false" HeaderText="Areas of Work">
                                        <ItemTemplate>

                                            <asp:Label ID="lblworkareas" Visible="true" ClientIDMode="Static" runat="server"
                                                Text='<%#Eval("Areas_of_Work")%>'>
                                            </asp:Label>
                                            <itemstyle width="100px" />
                                        </ItemTemplate>
                                        <ItemStyle Wrap="True" />
                                    </asp:TemplateField>
                                    <asp:TemplateField Visible="true" HeaderStyle-Wrap="false" HeaderText="Most Significant Contribution">
                                        <ItemTemplate>
                                            <asp:Label ID="lblmostsignificantcontribution" Width="100%" Visible="true" ClientIDMode="Static" runat="server"
                                                Text='<%#Eval("Most_Significant_Contribution")%>'>
                                            </asp:Label>
                                        </ItemTemplate>
                                        <ItemStyle Width="100px" />
                                    </asp:TemplateField>
                                    <asp:TemplateField Visible="true" HeaderStyle-Wrap="false" HeaderText="Achievements">
                                        <ItemTemplate>
                                            <asp:Label ID="lblachievements" Width="100%" Visible="true" ClientIDMode="Static" runat="server"
                                                Text='<%#Eval("Achievements")%>'>
                                            </asp:Label>
                                        </ItemTemplate>
                                        <ItemStyle Width="100px" />
                                    </asp:TemplateField>
                                    <asp:TemplateField Visible="true" HeaderStyle-Wrap="false" HeaderText="Shortcomings">
                                        <ItemTemplate>
                                            <asp:Label ID="lblshortcomings" Width="100%" Visible="true" ClientIDMode="Static" runat="server"
                                                Text='<%#Eval("Shortcomings")%>'>
                                            </asp:Label>
                                        </ItemTemplate>
                                        <ItemStyle Width="100px" />
                                    </asp:TemplateField>
                                    <asp:TemplateField Visible="true" HeaderStyle-Wrap="false" HeaderText="Field Trip Work">
                                        <ItemTemplate>
                                            <asp:Label ID="lblfieldtripwork" Width="100%" Visible="true" ClientIDMode="Static" runat="server"
                                                Text='<%#Eval("Field_Trip_Work")%>'>
                                            </asp:Label>
                                        </ItemTemplate>
                                        <ItemStyle Width="100px" />
                                    </asp:TemplateField>
                                    <asp:TemplateField Visible="true" HeaderStyle-Wrap="false" HeaderText="Other Work Areas of Interest">
                                        <ItemTemplate>
                                            <asp:Label ID="lblotherworkareasofinterest" Width="100%" Visible="true" ClientIDMode="Static" runat="server"
                                                Text='<%#Eval("Other_Work_Areas_of_Interest")%>'>
                                            </asp:Label>
                                        </ItemTemplate>
                                        <ItemStyle Width="100px" />
                                    </asp:TemplateField>
                                    <asp:TemplateField Visible="true" HeaderStyle-Wrap="false" HeaderText="Areas of Training">
                                        <ItemTemplate>
                                            <asp:Label ID="lblareasoftraining" Width="100%" Visible="true" ClientIDMode="Static" runat="server"
                                                Text='<%#Eval("Areas_of_Training")%>'>
                                            </asp:Label>
                                        </ItemTemplate>
                                        <ItemStyle Width="100px" />
                                    </asp:TemplateField>




                                </Columns>
                                <HeaderStyle BackColor="#5D7B9D" Font-Names="Yu Gothic" Font-Size="Small" Font-Bold="True" ForeColor="White" />
                       
                                </asp:GridView>
                        </section>
                              </div>
                                               </ContentTemplate>        
                 
                                                <Triggers>
                                                    <asp:PostBackTrigger ControlID="employee_filled_performance_appraisal" />
                                                </Triggers>
                                                
            </asp:UpdatePanel>
            
            </form>
        
                        </section>
    <script>
        function checkbtn() {
            alert("button pressed");
        }
    </script>
     
</asp:Content>

 

 

 

 

 

 

 

 

 

Why "lnkUpdate" button is not responding to any event , kindly help. could not get solution anywhere

No RepliesBe the first to reply

Resources