here i have five columns in Employee Named{ Id,Name,Department Id,Location,Salary} and my requirement is to find the details of the Employee based on Id Column when we enter the id in the texbox we should be able to display the Name,Department Id,Location,Salary in the rest of the textboxes.
i have tried the one and written the code as followed in the data access layer
public void findrecord(clsbo objbo)
{
try
{
con.Open();
SqlCommand cmd = new SqlCommand("search_tblEmployee ", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Name", objbo._Name);
cmd.Parameters.AddWithValue("@DepartmentId", objbo._DepartmentId);
cmd.Parameters.AddWithValue("@Location", objbo._Location);
cmd.Parameters.AddWithValue("@Salary", objbo._Salary);
}
catch (Exception ex)
{
throw ex;
}
finally
{
con.Close();
}
In presentation layer code behind
protected void btnfind_Click(object sender, EventArgs e)
{
try
{
clsbo objbo = new clsbo();
clsbll objbll = new clsbll();
objbo._Id = Convert.ToInt32(txtid.Text);
objbo._Name = txtname.Text;
objbo._DepartmentId = Convert.ToInt32(txtdepartmentid.Text);
objbo._Salary = Convert.ToInt32(txtsalary.Text);
objbo._Location = txtlocation.Text;
objbll.FindRecord(objbo);
Label1.Text = "Record Found";
}
catch (Exception ex)
{
throw ex;
}
and business Logic layer
public void FindRecord(clsbo objbo)
{
clsdal objdal = new clsdal();
try
{
objdal.findrecord(objbo);
}
catch(Exception ex)
{
throw ex;
}
but when i enter id in the textbox i'am getting the error as
Input string was not in a correct format.
Help me Out Thanks in Advance