My 3 tier application has a gridview with rowupdating event. I am passing a method to DAL for my row update in gridview.
Everything is working fine, values are getting updated in the sql table. But, On success, the value which is returned back is either 3 or 4, why is it happening? I am confused! I need the reason for this.
Here is my Rowupdating event.
protected void gvTask_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int EID = Convert.ToInt32(gvTask.DataKeys[e.RowIndex].Value.ToString());
string username = gvTask.DataKeys[e.RowIndex].Values["Username"].ToString();
TextBox txtProjectName = (TextBox)gvTask.Rows[e.RowIndex].FindControl("txtProjectName");
TextBox txtClientName = (TextBox)gvTask.Rows[e.RowIndex].FindControl("txtClientName");
TextBox txtStatus = (TextBox)gvTask.Rows[e.RowIndex].FindControl("txtStatus");
TextBox txtStartDate = (TextBox)gvTask.Rows[e.RowIndex].FindControl("txtStartDate");
TextBox txtEndDate = (TextBox)gvTask.Rows[e.RowIndex].FindControl("txtEndDate");
TextBox txtReportingManager = (TextBox)gvTask.Rows[e.RowIndex].FindControl("txtReportingManager");
TextBox txtComments = (TextBox)gvTask.Rows[e.RowIndex].FindControl("txtComments");
int updateInfo = objTABAL.UpdateTaskAsignmentDetailsBAL(EID,username,txtProjectName.Text,txtClientName.Text,txtStatus.Text,txtStartDate.Text,txtEndDate.Text,txtReportingManager.Text,txtComments.Text);
if (updateInfo == 3)
{
lblresult.ForeColor = Color.Green;
lblresult.Text = username + " Details Updated successfully";
gvTask.EditIndex = -1;
BindEmployeeDetails();
}
}
next follows my DAL class method.
public int UpdateTaskAsignmentDetailsDAL(int EID, string username, string ProjectName, string ClientName, string Status, string StartDate, string EndDate, string ReportingManager,string comments)
{
int ReturnValue=0;
try
{
con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand("spUpdateTaskAssignment", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@EID", EID);
cmd.Parameters.Add("@ProjectName", ProjectName);
cmd.Parameters.Add("@ClientName", ClientName);
cmd.Parameters.Add("@Status", Status);
cmd.Parameters.Add("@StartDate", StartDate);
cmd.Parameters.Add("@EndDate", EndDate);
cmd.Parameters.Add("@ReportingManager", ReportingManager);
cmd.Parameters.Add("@Comments", comments);
ReturnValue= cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
}
finally
{
con.Close();
con.Dispose();
}
return ReturnValue;
}
please help me out and if possible explain the situation, why it returns 3.
Thanks