protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
int PID =Convert.ToInt32( GridView1.Rows[e.RowIndex].Cells[3].Text.Trim());
string ProjCode = GridView1.Rows[e.RowIndex].Cells[4].Text.ToString();
string ProjName = GridView1.Rows[e.RowIndex].Cells[5].Text.ToString();
int CPID = Convert.ToInt32(GridView1.Rows[e.RowIndex].Cells[6].Text.ToString());
string ChkProjCode = GridView1.Rows[e.RowIndex].Cells[7].Text.ToString();
string CheckProj = GridView1.Rows[e.RowIndex].Cells[8].Text.ToString();
string CKProjYear = GridView1.Rows[e.RowIndex].Cells[9].Text.ToString();
string ProjGrade = GridView1.Rows[e.RowIndex].Cells[10].Text.ToString(); string Office = GridView1.Rows[e.RowIndex].Cells[11].Text.ToString();
string ProjYear = GridView1.Rows[e.RowIndex].Cells[12].Text.ToString();
string Currency = GridView1.Rows[e.RowIndex].Cells[13].Text.ToString();
DateTime ProjEnsureDate = Convert.ToDateTime(GridView1.Rows[e.RowIndex].Cells[14].Text.ToString());
int ACompanyID = Convert.ToInt32(GridView1.Rows[e.RowIndex].Cells[15].Text.ToString());
int BCompanyID = Convert.ToInt32(GridView1.Rows[e.RowIndex].Cells[16].Text.ToString());
string OrgID = GridView1.Rows[e.RowIndex].Cells[17].Text.ToString();
string OrgName = GridView1.Rows[e.RowIndex].Cells[18].Text.ToString();
string BigDeptID = GridView1.Rows[e.RowIndex].Cells[19].Text.ToString();
string BigDeptName = GridView1.Rows[e.RowIndex].Cells[20].Text.ToString();
string DeptID = GridView1.Rows[e.RowIndex].Cells[21].Text.ToString();
string DeotName = GridView1.Rows[e.RowIndex].Cells[22].Text.ToString();
string AOrgName = GridView1.Rows[e.RowIndex].Cells[23].Text.ToString();
string BOrgName = GridView1.Rows[e.RowIndex].Cells[24].Text.ToString();
string Country = GridView1.Rows[e.RowIndex].Cells[25].Text.ToString();
string Location = GridView1.Rows[e.RowIndex].Cells[26].Text.ToString();
string Status = GridView1.Rows[e.RowIndex].Cells[27].Text.ToString();
DateTime PlanStartDate = Convert.ToDateTime(GridView1.Rows[e.RowIndex].Cells[28].Text.ToString());
DateTime PlanEndDate = Convert.ToDateTime(GridView1.Rows[e.RowIndex].Cells[29].Text.ToString());
DateTime TrueStartDate = Convert.ToDateTime(GridView1.Rows[e.RowIndex].Cells[30].Text.ToString()); DateTime TrueEndDate = Convert.ToDateTime(GridView1.Rows[e.RowIndex].Cells[31].Text.ToString());
decimal ContractFee = Convert.ToDecimal(GridView1.Rows[e.RowIndex].Cells[32].Text.ToString());
decimal ProjFee = Convert.ToDecimal(GridView1.Rows[e.RowIndex].Cells[33].Text.ToString());
string CCode = GridView1.Rows[e.RowIndex].Cells[34].Text.ToString();
string ClientCCode = GridView1.Rows[e.RowIndex].Cells[35].Text.ToString();
string ContractStatus = GridView1.Rows[e.RowIndex].Cells[36].Text.ToString();
string Memo = GridView1.Rows[e.RowIndex].Cells[37].Text.ToString();
DateTime CreatDate = Convert.ToDateTime(GridView1.Rows[e.RowIndex].Cells[38].Text.ToString());
string Creater = GridView1.Rows[e.RowIndex].Cells[39].Text.ToString(); string sqlStrC = "update TSS_ProjectInfo set PID =" + PID + ",ProjCode='" + ProjCode + "',ProjName='" + ProjName + "',CPID='" + CPID + "',ChkProjCode='" + ChkProjCode + "' ";
string sqlStrD = ",CheckProj='" + CheckProj + "',CKProjYear='" + CKProjYear + "',ProjGrade='" + ProjGrade + "',Office='" + Office + "',ProjYear='" + ProjYear + "',Currency='" + Currency + "',ProjEnsureDate=" + ProjEnsureDate + ",ACompanyID='" + ACompanyID + "',BCompanyID='" + BCompanyID + "',OrgID='" + OrgID + "'";
string sqlStrE = ",OrgName='" + OrgName + "',BigDeptID='" + BigDeptID + "',BigDeptName='" + BigDeptName + "',DeptID='" + DeptID + "',DeotName='" + DeotName + "',AOrgName='" + AOrgName + "',BOrgName='" + BOrgName + "',Country='" + Country + "',Location='" + Location + "',Status='" + Status + "'";
string sqlStrF = ",PlanStartDate=" + PlanStartDate + ",PlanEndDate=" + PlanEndDate + ",TrueStartDate=" + TrueStartDate + "',TrueEndDate=" + TrueEndDate + ",ContractFee=" + ContractFee + ",ProjFee=" + ProjFee + ",CCode='" + CCode + "',ClientCCode='" + ClientCCode + "',ContractStatus='" + ContractStatus + "',Memo='" + Memo + "',CreatDate='" + CreatDate + "' where PID=" + id + "";
string sqlStr = sqlStrC + sqlStrD + sqlStrE + sqlStrF;我 点编辑以后,更新会有问题:
“/UDS”应用程序中的服务器错误。
--------------------------------------------------------------------------------输入字符串的格式不正确。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.FormatException: 输入字符串的格式不正确。源错误:
行 219: {
行 220: string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
行 221: int PID =Convert.ToInt32( GridView1.Rows[e.RowIndex].Cells[3].Text.Trim());
行 222:
行 223: string ProjCode = GridView1.Rows[e.RowIndex].Cells[4].Text.ToString();
其中 int PID =Convert.ToInt32( GridView1.Rows[e.RowIndex].Cells[3].Text.Trim());
这句,我修改了N次都未成功,例如修改位:
int PID = Convert.ToInt32( GridView1.Rows[e.RowIndex].Cells[3].Text.TOString());
也是不行的。
{
string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
int PID =Convert.ToInt32( GridView1.Rows[e.RowIndex].Cells[3].Text.Trim());
string ProjCode = GridView1.Rows[e.RowIndex].Cells[4].Text.ToString();
string ProjName = GridView1.Rows[e.RowIndex].Cells[5].Text.ToString();
int CPID = Convert.ToInt32(GridView1.Rows[e.RowIndex].Cells[6].Text.ToString());
string ChkProjCode = GridView1.Rows[e.RowIndex].Cells[7].Text.ToString();
string CheckProj = GridView1.Rows[e.RowIndex].Cells[8].Text.ToString();
string CKProjYear = GridView1.Rows[e.RowIndex].Cells[9].Text.ToString();
string ProjGrade = GridView1.Rows[e.RowIndex].Cells[10].Text.ToString(); string Office = GridView1.Rows[e.RowIndex].Cells[11].Text.ToString();
string ProjYear = GridView1.Rows[e.RowIndex].Cells[12].Text.ToString();
string Currency = GridView1.Rows[e.RowIndex].Cells[13].Text.ToString();
DateTime ProjEnsureDate = Convert.ToDateTime(GridView1.Rows[e.RowIndex].Cells[14].Text.ToString());
int ACompanyID = Convert.ToInt32(GridView1.Rows[e.RowIndex].Cells[15].Text.ToString());
int BCompanyID = Convert.ToInt32(GridView1.Rows[e.RowIndex].Cells[16].Text.ToString());
string OrgID = GridView1.Rows[e.RowIndex].Cells[17].Text.ToString();
string OrgName = GridView1.Rows[e.RowIndex].Cells[18].Text.ToString();
string BigDeptID = GridView1.Rows[e.RowIndex].Cells[19].Text.ToString();
string BigDeptName = GridView1.Rows[e.RowIndex].Cells[20].Text.ToString();
string DeptID = GridView1.Rows[e.RowIndex].Cells[21].Text.ToString();
string DeotName = GridView1.Rows[e.RowIndex].Cells[22].Text.ToString();
string AOrgName = GridView1.Rows[e.RowIndex].Cells[23].Text.ToString();
string BOrgName = GridView1.Rows[e.RowIndex].Cells[24].Text.ToString();
string Country = GridView1.Rows[e.RowIndex].Cells[25].Text.ToString();
string Location = GridView1.Rows[e.RowIndex].Cells[26].Text.ToString();
string Status = GridView1.Rows[e.RowIndex].Cells[27].Text.ToString();
DateTime PlanStartDate = Convert.ToDateTime(GridView1.Rows[e.RowIndex].Cells[28].Text.ToString());
DateTime PlanEndDate = Convert.ToDateTime(GridView1.Rows[e.RowIndex].Cells[29].Text.ToString());
DateTime TrueStartDate = Convert.ToDateTime(GridView1.Rows[e.RowIndex].Cells[30].Text.ToString()); DateTime TrueEndDate = Convert.ToDateTime(GridView1.Rows[e.RowIndex].Cells[31].Text.ToString());
decimal ContractFee = Convert.ToDecimal(GridView1.Rows[e.RowIndex].Cells[32].Text.ToString());
decimal ProjFee = Convert.ToDecimal(GridView1.Rows[e.RowIndex].Cells[33].Text.ToString());
string CCode = GridView1.Rows[e.RowIndex].Cells[34].Text.ToString();
string ClientCCode = GridView1.Rows[e.RowIndex].Cells[35].Text.ToString();
string ContractStatus = GridView1.Rows[e.RowIndex].Cells[36].Text.ToString();
string Memo = GridView1.Rows[e.RowIndex].Cells[37].Text.ToString();
DateTime CreatDate = Convert.ToDateTime(GridView1.Rows[e.RowIndex].Cells[38].Text.ToString());
string Creater = GridView1.Rows[e.RowIndex].Cells[39].Text.ToString(); string sqlStrC = "update TSS_ProjectInfo set PID =" + PID + ",ProjCode='" + ProjCode + "',ProjName='" + ProjName + "',CPID='" + CPID + "',ChkProjCode='" + ChkProjCode + "' ";
string sqlStrD = ",CheckProj='" + CheckProj + "',CKProjYear='" + CKProjYear + "',ProjGrade='" + ProjGrade + "',Office='" + Office + "',ProjYear='" + ProjYear + "',Currency='" + Currency + "',ProjEnsureDate=" + ProjEnsureDate + ",ACompanyID='" + ACompanyID + "',BCompanyID='" + BCompanyID + "',OrgID='" + OrgID + "'";
string sqlStrE = ",OrgName='" + OrgName + "',BigDeptID='" + BigDeptID + "',BigDeptName='" + BigDeptName + "',DeptID='" + DeptID + "',DeotName='" + DeotName + "',AOrgName='" + AOrgName + "',BOrgName='" + BOrgName + "',Country='" + Country + "',Location='" + Location + "',Status='" + Status + "'";
string sqlStrF = ",PlanStartDate=" + PlanStartDate + ",PlanEndDate=" + PlanEndDate + ",TrueStartDate=" + TrueStartDate + "',TrueEndDate=" + TrueEndDate + ",ContractFee=" + ContractFee + ",ProjFee=" + ProjFee + ",CCode='" + CCode + "',ClientCCode='" + ClientCCode + "',ContractStatus='" + ContractStatus + "',Memo='" + Memo + "',CreatDate='" + CreatDate + "' where PID=" + id + "";
string sqlStr = sqlStrC + sqlStrD + sqlStrE + sqlStrF;我 点编辑以后,更新会有问题:
“/UDS”应用程序中的服务器错误。
--------------------------------------------------------------------------------输入字符串的格式不正确。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.FormatException: 输入字符串的格式不正确。源错误:
行 219: {
行 220: string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
行 221: int PID =Convert.ToInt32( GridView1.Rows[e.RowIndex].Cells[3].Text.Trim());
行 222:
行 223: string ProjCode = GridView1.Rows[e.RowIndex].Cells[4].Text.ToString();
其中 int PID =Convert.ToInt32( GridView1.Rows[e.RowIndex].Cells[3].Text.Trim());
这句,我修改了N次都未成功,例如修改位:
int PID = Convert.ToInt32( GridView1.Rows[e.RowIndex].Cells[3].Text.TOString());
也是不行的。
protected void EditToTextBox(int ss)
{
ViewState["flag"] = 1;
this.pnlProjInfo.Visible = true;
PID = Server.HtmlEncode(((Label)GridView1.Rows[ss].Cells[3].Controls[1]).Text.ToString());
lbPID.Text = PID;
this.txtProjName.Text = Server.HtmlEncode(((Label)GridView1.Rows[ss].Cells[5].Controls[1]).Text.ToString());
this.txtCPID.Text = Server.HtmlEncode(((Label)GridView1.Rows[ss].Cells[6].Controls[1]).Text.ToString());
this.txtProjFee.Text = Server.HtmlEncode(((Label)GridView1.Rows[ss].Cells[33].Controls[1]).Text.ToString());
this.txtBigDeptName.Text = Server.HtmlEncode(((Label)GridView1.Rows[ss].Cells[20].Controls[1]).Text.ToString());
this.txtDeotName.Text = Server.HtmlEncode(((Label)GridView1.Rows[ss].Cells[22].Controls[1]).Text.ToString());
this.txtAOrgName.Text = Server.HtmlEncode(((Label)GridView1.Rows[ss].Cells[23].Controls[1]).Text.ToString());
this.txtBOrgName.Text = Server.HtmlEncode(((Label)GridView1.Rows[ss].Cells[24].Controls[1]).Text.ToString());
this.txtProjCode.Text = Server.HtmlEncode(((Label)GridView1.Rows[ss].Cells[4].Controls[1]).Text.ToString());
this.txtCountry.Text = Server.HtmlEncode(((Label)GridView1.Rows[ss].Cells[25].Controls[1]).Text.ToString());
this.txtLocation.Text = Server.HtmlEncode(((Label)GridView1.Rows[ss].Cells[26].Controls[1]).Text.ToString());
this.txtPlanStartDate.Text = Server.HtmlEncode(((Label)GridView1.Rows[ss].Cells[28].Controls[1]).Text.ToString());
this.txtPlanEndDate.Text = Server.HtmlEncode(((Label)GridView1.Rows[ss].Cells[29].Controls[1]).Text.ToString());
this.txtTrueStartDate.Text = Server.HtmlEncode(((Label)GridView1.Rows[ss].Cells[30].Controls[1]).Text.ToString());
this.txtTrueEndDate.Text = Server.HtmlEncode(((Label)GridView1.Rows[ss].Cells[31].Controls[1]).Text.ToString());
SetReturnEdit(pnlProjInfo);
}执行编辑 功能
protected void EditPorjInfo()
{
//string PID = GridView1.SelectedDataKey.Value.ToString();
//string TPID = this.txtTPID.Text.ToString();
//string pid = GridView1.DataKeys[GridView1.EditIndex].Value[0].ToString();
string c = lbPID.Text;
int pid = Convert.ToInt32(c);
string ProjCode = this.txtProjCode.Text.ToString();
string ProjName = this.txtProjName.Text.ToString();
string CPID = this.txtCPID.Text.ToString();
//string ProjGrade = this.txtProjGrade.Text.ToString();
string Country = this.txtCountry.Text.ToString();
string Location = this.txtLocation.Text.ToString();
string BigDeptName = this.txtBigDeptName.Text.ToString();
string DeotName = this.txtDeotName.Text.ToString();
string AOrgName = this.txtAOrgName.Text.ToString();
string BOrgName = this.txtBOrgName.Text.ToString(); //---zuohd 修改日期为字符类型 begin ---
string PlanStartDate = this.txtPlanStartDate.Text.ToString();
string PlanEndDate = this.txtPlanEndDate.Text.ToString();
string TrueStartDate = this.txtTrueStartDate.Text.ToString();
string TrueEndDate = this.txtTrueEndDate.Text.ToString();
//-----------End----------------
decimal ProjFee = Convert.ToDecimal(this.txtProjFee.Text.ToString()); string sqlStrC = "update TSS_ProjectInfo set ProjCode='" + ProjCode + "',ProjName='" + ProjName + "',Country='" + Country + "',Location='" + Location + "',CPID='" + CPID + "'";
string sqlStrD = ",BigDeptName='" + BigDeptName + "',DeotName='" + DeotName + "',AOrgName='" + AOrgName + "',BOrgName='" + BOrgName + "'";
string sqlStrE = ",PlanStartDate='" + PlanStartDate + "',PlanEndDate='" + PlanEndDate + "',TrueStartDate='" + TrueStartDate + "',TrueEndDate='" + TrueEndDate + "',ProjFee=" + ProjFee + " where TPID=" + pid;
string sqlStr = sqlStrC + sqlStrD + sqlStrE; int flag2 = DbAccess.Execute(sqlStr);
if (flag2 > 0)
{
Response.Write("<script>alert('项目信息更新成功!');</script>");
//gvBasicinfo.EditIndex = -1;
GridView1.EditIndex = -1;
DataBound(ProjYear);
}
else
{
Response.Write("<script>alert('项目信息更新失败!');</script>");
}
}