yati says:
if (!IsPostBack)
{
con.Open();
if (!String.IsNullOrEmpty(Request.QueryString["CpID"]))
{
PanelAddCareerPro.Visible = false;
PanelEditCareerPro.Visible = true;
string queryCP = "SELECT * FROM CareerProgress WHERE CpID=@CpID";
SqlCommand cmdCProgress = new SqlCommand(queryCP, con);
cmdCProgress.Parameters.AddWithValue("@CpID", CpID);
SqlDataReader drCareerPro = cmdCProgress.ExecuteReader();
if (drCareerPro.Read())
{
txtCPcompName2.Text = drCareerPro["CpCompName"].ToString();
txtCPcompAddr2.Text = drCareerPro["CpCompAddress"].ToString();
if (drCareerPro["CpDateJoined"] is DBNull)
txtCpDateJoin2.Text = "";
else
txtCpDateJoin2.Text = Convert.ToDateTime(drCareerPro["CpDateJoined"]).ToString("dd/MM/yyyy");
if (drCareerPro["CpLastDate"] is DBNull)
txtcCpLWD2.Text = "";
else
txtcCpLWD2.Text = Convert.ToDateTime(drCareerPro["CpLastDate"]).ToString("dd/MM/yyyy");
if (drCareerPro["CpSBS"] is DBNull)
ddlCPsbs.SelectedValue = "";
else
ddlCPsbs.SelectedValue = drCareerPro["CpSBS"].ToString();
if (drCareerPro["CpSLastDate"] is DBNull)
txtLastDate2.Text = "";
else
txtLastDate2.Text = Convert.ToDateTime(drCareerPro["CpSLastDate"]).ToString("dd/MM/yyyy");
txtCpPosition2.Text = drCareerPro["CpPosition"].ToString();
txtCpPeriodServe2.Text = drCareerPro["CpActPeriodServe"].ToString();
txtBalContrBond2.Text = drCareerPro["CpBalContractBond"].ToString();
txtSchoolAmount2.Text = drCareerPro["CpTotal"].ToString();
txtCpRemarks2.Text = drCareerPro["CpRemarks"].ToString();
}
drCareerPro.Close();
}
else
{
PanelAddCareerPro.Visible = true;
PanelEditCareerPro.Visible = false;
}
}
con.Close();
replace above code with below
if (!IsPostBack)
{
con.Open();
if (!String.IsNullOrEmpty(Request.QueryString["CpID"]))
{
hfSelectedTab.Value = "6";
PanelAddCareerPro.Visible = false;
PanelEditCareerPro.Visible = true;
// retrieve Career Progress
string queryCP = "SELECT * FROM CareerProgress WHERE CpID=@CpID";
SqlCommand cmdCProgress = new SqlCommand(queryCP, con);
cmdCProgress.Parameters.AddWithValue("@CpID", CpID);
SqlDataReader drCareerPro = cmdCProgress.ExecuteReader();
if (drCareerPro.Read())
{
txtCPcompName2.Text = drCareerPro["CpCompName"].ToString();
txtCPcompAddr2.Text = drCareerPro["CpCompAddress"].ToString();
//txtCpDateJoin.Text = drCareerPro["ContactAddress"].ToString();
if (drCareerPro["CpDateJoined"] is DBNull)
txtCpDateJoin2.Text = "";
else
txtCpDateJoin2.Text = Convert.ToDateTime(drCareerPro["CpDateJoined"]).ToString("dd/MM/yyyy");
//txtcCpLWD.Text = drCareerPro["ContactMobileNo"].ToString();
if (drCareerPro["CpLastDate"] is DBNull)
txtcCpLWD2.Text = "";
else
txtcCpLWD2.Text = Convert.ToDateTime(drCareerPro["CpLastDate"]).ToString("dd/MM/yyyy");
if (drCareerPro["CpSBS"] is DBNull)
ddlCPsbs.SelectedValue = "";
else
ddlCPsbs.SelectedValue = drCareerPro["CpSBS"].ToString();
//txtLastDate.Text = drCareerPro["ContactRemark"].ToString();
if (drCareerPro["CpSLastDate"] is DBNull)
txtLastDate2.Text = "";
else
txtLastDate2.Text = Convert.ToDateTime(drCareerPro["CpSLastDate"]).ToString("dd/MM/yyyy");
txtCpPosition2.Text = drCareerPro["CpPosition"].ToString();
txtCpPeriodServe2.Text = drCareerPro["CpActPeriodServe"].ToString();
txtBalContrBond2.Text = drCareerPro["CpBalContractBond"].ToString();
txtSchoolAmount2.Text = drCareerPro["CpTotal"].ToString();
txtCpRemarks2.Text = drCareerPro["CpRemarks"].ToString();
}
drCareerPro.Close();
}
else
{
PanelAddCareerPro.Visible = true;
PanelEditCareerPro.Visible = false;
}
}
con.Close();