Thursday, November 24, 2022

Binding of Data to Textboxes by clicking on button ASP.NET C#

 {

 ddlPnlCadreType.DataSource = Repository.GetCadreType();

                ddlPnlCadreType.DataTextField = "CadreType";

                ddlPnlCadreType.DataValueField = "CadreTypeID";

                ddlPnlCadreType.DataBind();

BindEmployee(id, "", true);

}


 private void BindEmployee(long ID, String DOR, bool Approved)

        {

          


            SqlParameter[] param = { new SqlParameter("ID", ID) };

            DataTable dt = new DataAccess().Read("read_employeebyid", param).Tables[0];

            ViewState["ID"] = ID;

            ViewState["MainID"] = dt.Rows[0]["MainID"].ToString(); ;

            //string Institute = dt.Rows[0]["Institute"].ToString();

            //ddlInstitute.SelectedIndex = ddlInstitute.Items.IndexOf(ddlInstitute.Items.FindByText(Institute));

            ddlPnlCadreType.SelectedValue = dt.Rows[0]["CadreTypeID"].ToString();

            ddlPnlPreviousOrganization.SelectedValue = dt.Rows[0]["PreviousOrganization"].ToString();


            //String Discipline = dt.Rows[0]["Discipline"].ToString();

            //ddlDiscipline.SelectedIndex = ddlDiscipline.Items.IndexOf(ddlDiscipline.Items.FindByText(Discipline));



            ddlPnlDiscipline.SelectedValue = dt.Rows[0]["DisciplineID"].ToString();

            ddlPnlAdjustedDiscipline.SelectedValue = dt.Rows[0]["AdjustedDisciplineID"].ToString();


            ddlPnlTitle.SelectedValue = dt.Rows[0]["Title"].ToString();

            txtPnlName.Text = dt.Rows[0]["Name"].ToString();

            txtPnlFMSID.Text = dt.Rows[0]["FMSID"].ToString();


            ddlPnlGender.SelectedValue = dt.Rows[0]["Gender"].ToString();

            ddlPnlCategory.SelectedValue = dt.Rows[0]["Category"].ToString();

            ddlPnlRosterCategory.SelectedValue = dt.Rows[0]["RosterCategory"].ToString();

            txtPnlDob.Text = dt.Rows[0]["DOB"].ToString();

            txtPnlApointmentDate.Text = dt.Rows[0]["AppointmentDate"].ToString();


            ddlPnlDesignation.SelectedValue = dt.Rows[0]["PresentDesignationID"].ToStri


            ddlPnlInstitute.SelectedValue = dt.Rows[0]["InstituteID"].ToString();

            BindRegionalStation(Convert.ToInt32(ddlPnlInstitute.SelectedValue));

            ddlPnlRegionalStation.DataTextField = "RSName";

            ddlPnlRegionalStation.DataValueField = "rsInstituteID_cms";

            ddlPnlRegionalStation.DataBind();

            ddlPnlRegionalStation.Items.Insert(0, new ListItem("Main Institute", Int32.Parse(ddlPnlInstitute.SelectedValue).ToString()));

            ddlPnlRegionalStation.SelectedValue = dt.Rows[0]["I_Code"].ToString();


            txtPnlMobile.Text = dt.Rows[0]["Mobile"].ToString();

            txtPnlEmail.Text = dt.Rows[0]["Email"].ToString();

            //new SqlParameter("DOR", DOR.Trim()),

            txtPnlDeputationFrom.Text = dt.Rows[0]["DeputationFrom"].ToString();

            txtPnlDeputationTo.Text = dt.Rows[0]["DeputationTo"].ToString();



            txtPnlStudyLeaveTo.Text = dt.Rows[0]["StudyLeaveTo"].ToString();


            txtPnlRemarks.Text = dt.Rows[0]["Remarks"].ToString();

            txtPnlInstRemarks.Text = dt.Rows[0]["InstituteRemarks"].ToString();


            chkPnlWSP.Checked = Convert.ToBoolean(dt.Rows[0]["WSP"].ToString());

            //new SqlParameter("State", ""),

            //new SqlParameter("Approved", Approved),


            btnPnlUpdate.Text = "Update";

        }

No comments:

Post a Comment