protected void btnSubmit_Click(object sender, EventArgs e)
{
Library lib = new Library();
string sEmpCode = Request.QueryString["empcode"].ToString();
if (Request.QueryString["comcode"].ToString() == "MEHTASCL")
{
string company = Request.QueryString["comcode"].ToString();
string location = "RNV";
string strArea = ddrarea.SelectedValue.Trim();
string strDepartment = ddrDepartment.SelectedValue.Trim();
string strCatagory = ddrCatagory.SelectedValue.Trim();
string strDesignation = lblDesignation.Text.Trim();
string strSubCatagory = ddrSubCatagory.SelectedValue.Trim();
string strTitle = txtTitle.Value.Trim();
string strDescription = txtDescription.Value.Trim();
string strStatus = ddrStatus.SelectedValue.Trim();
string strsolution = txtsolution.Value.Trim();
string ack = lib.InsertData(company, location, "1", strDesignation, sEmpCode, strDepartment, strArea, strCatagory, strSubCatagory, strTitle, strDescription, strStatus, strsolution);
}
lblMsg.Text = "Data Submitted Successfully";
}
This is your code, you suggest declare your string(s) outside the button code with empty text.
string abc = "";
When you click the button, initially all the variables (string abc) are empty, so button function will fill the values. Next time when you click the button, the variables you declared outside the button scope are empty when the button function fills the values. I hope it will work gently. :doh:
Sample for you:
string sEmpCode = "";
string company = "";
string location = "";
string strArea = "";
string strDepartment = "";
string strCatagory = "";
string strDesignation = "";
string strSubCatagory = "";
string strTitle = "";
string strDescription = "";
string strStatus = "";
string strsolution = "";
string ack = "";
lblMsg.Text = "";
Library lib = new Library();
sEmpCode = Request.QueryString["empcode"].ToString();
if (Request.QueryString["comcode"].ToString() == "MEHTASCL")
{
company = Request.QueryString["comcode"].ToString();
location = "RNV";
strArea = ddrarea.SelectedValue.Trim();
strDepartment = ddrDepartment.SelectedValue.Trim();
strCatagory = ddrCatagory.SelectedValue.Trim();
strDesignation = lblDesignation.Text.Trim();
strSubCatagory = ddrSubCatagory.SelectedValue.Trim();
strTitle = txtTitle.Value.Trim();
strDescription = txtDescription.Value.Trim();
strStatus = ddrStatus.SelectedValue.Trim();
strsolution = txtsolution.Value.Trim();
ack = lib.InsertData(company, location, "1", strDesignation, sEmpCode, strDepartment, strArea, strCatagory, strSubCatagory, strTitle, strDescription, strStatus, strsolution);
}
lblMsg.Text = "Data Submitted Successfully";