我的项目在服务器上给出此错误,但在本地系统中工作良好.FormatException:字符串没有被识别为有效的日期时间
本文关键字:字符串 FormatException 识别 日期 时间 有效 项目 服务器 错误 系统 我的 | 更新日期: 2023-09-27 18:09:07
我的软件在服务器上给出这个错误
系统。FormatException:字符串未被识别为有效的日期时间。
它在本地工作很好,我使用jquery的日期时间。我的日期格式是dd-mm-yyyy,它昨晚工作正常,但早上给我这个错误。
protected void btnapprove_Click(object sender, EventArgs e)
{
if (btnapprove.Text == "Approve")
if (txtremark.Text != "")
{
fillSaveapprove();
SaveProposalregis["IsActive"] = "Approve";
string str = lo.SaveProposalregis(SaveProposalregis);
if (str == "Save")
{
cleartext();
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "alert", "alert('Approve Successfull')", true);
GridViewregis.DataBind();
panelgridview.Visible = true;
GridViewregis.Visible = true;
}
else
{
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "alert", "alert('Status Not Update SuccessFully')", true);
panelgridview.Visible = false;
panelshow.Visible = false;
}
}
else
{
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "alert", "alert('Please Fill Remark')", true);
panelgridview.Visible = true;
panelshow.Visible = true;
}
}
public void fillSaveapprove()
{
SaveProposalregis["id"] = Convert.ToInt64(hid.Value);
SaveProposalregis["plvcid"] = Convert.ToInt64(plvcid.Value);
SaveProposalregis["bankname"] = lblbankname.Text;
SaveProposalregis["Address"] = lbladd.Text;
SaveProposalregis["First_Name"] = lblfirstname.Text;
SaveProposalregis["Last_Name"] = lblln.Text;
SaveProposalregis["Father_Name"] = lblfn.Text;
SaveProposalregis["DOB"] = lbldob.Text;
SaveProposalregis["Contact_No"] = lblconno.Text;
SaveProposalregis["Email_Id"] = lblemail.Text;
SaveProposalregis["Pan_Detail"] = lblpanno.Text;
SaveProposalregis["Nominee_Name"] = lblnomineename.Text;
SaveProposalregis["Gender"] = lblngender.Text;
SaveProposalregis["nominee_dob"] = lblndob.Text;
SaveProposalregis["nominiRelationwithroposer"] = lblnrwp.Text;
SaveProposalregis["l_a_Name"] = lbllaname.Text;
SaveProposalregis["l_a_gender"] = lbllagender.Text;
SaveProposalregis["l_a_dob"] = lblladob.Text;
SaveProposalregis["l_a_Relationwithroposer"] = lbllarew.Text;
SaveProposalregis["Application_No"] = lblappno.Text;
SaveProposalregis["Plan"] = lblplan.Text;
SaveProposalregis["Company_name"] = lblcompname.Text;
SaveProposalregis["Primium_paying_Term"] = lblppt.Text;
SaveProposalregis["Policy_Term"] = lblpt.Text;
SaveProposalregis["Mode_of_Payment"] = lblmop.Text;
SaveProposalregis["Cheque_No"] = lblcn.Text;
SaveProposalregis["Cheque_Amount"] = lblcamount.Text;
SaveProposalregis["Cheque_Date"] = lblchqdate.Text;
SaveProposalregis["Demand_Draft_No"] = lblddno.Text;
SaveProposalregis["DD_Payee_Name"] = lblddpayeename.Text;
SaveProposalregis["DD_amount"] = lblddamount.Text;
SaveProposalregis["dd_Date"] = lbldddate.Text;
SaveProposalregis["Primium_mode"] = lblprimiummode.Text;
SaveProposalregis["Employeee_code"] = lblempcode.Text;
SaveProposalregis["Manager"] = lblmanager.Text;
SaveProposalregis["Tl_name"] = lbltlname.Text;
SaveProposalregis["tc_name"] = lbltcname.Text;
SaveProposalregis["GrossPrimium"] = lblgrossprimium.Text;
SaveProposalregis["NetPrimium"] = lblnetprimium.Text;
SaveProposalregis["ModelPrimium"] = lblmodelprimium.Text;
SaveProposalregis["RegistrationDate"] = lbldate.Text;
SaveProposalregis["country"] = lblcountry.Text;
SaveProposalregis["state"] = lblstate.Text;
SaveProposalregis["city"] = lblcity.Text;
SaveProposalregis["pinno"] = lblpinno.Text;
SaveProposalregis["alternateno"] = lblalternateconno.Text;
SaveProposalregis["Remark"] = txtremark.Text;
SaveProposalregis["PlvcStatus"] = "Approve";
}`
这可能是由于您的本地计算机和服务器具有不同的文化(由于具有不同的区域设置)。
例如,如果您的本地计算机具有英国区域设置,因此具有DD/MM/YYYY日期格式,但您的服务器具有美国区域设置,因此具有MM/DD/YYYY日期格式。
例如,如果在英国机器上将2015年12月25日表示的日期转换为字符串,则会产生"25/12/2015",但是如果在美国机器上解析该日期,则会得到一个错误,因为没有25个月。
如果你想使用日期作为字符串,那么你需要允许不同的日期格式