输入字符串未处于正确格式错误将在下面的代码中检查此正确的代码。 [英] Input String Was Not In A Correct Format error will coming in following code check this correct code.

查看:96
本文介绍了输入字符串未处于正确格式错误将在下面的代码中检查此正确的代码。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

string mac_rate_eff_date = DateTime.Now.ToString("yy-M-dd");
       string FromDate = "";
       if (tabname == "ItemOfMachinery")
       {
           if (dbwork == "Insert")
           {
               imacc_id = int.Parse(drpcategoryofmachinery.SelectedValue);
               mac_code = txtcode.Text;
               ma_short_desc = txtshort.Text;
               mac_long_desc = txtDescription.Text;
               mac_unit = int.Parse(drpUnit.SelectedItem.Value);
               mac_rate = double.Parse(drpcategoryofmachinery.SelectedValue);
               FromDate = txteffdate.Text;

               string[] datesplit = FromDate.Split('-');
               mac_rate_eff_date = datesplit[2] + "-" + datesplit[1] + "-" + datesplit[0];

               if (datesplit[0].Length == 4)
               {
                   mac_rate_eff_date = datesplit[0] + "-" + datesplit[1] + "-" + datesplit[2];
               }
           }
           else
           {
               mac_id = int.Parse(hdnmac_id.Value);
               mac_rate_id = int.Parse(hdnmac_rate_id.Value);
               imacc_id = int.Parse(drpcategoryofmachinery.SelectedValue);
               ma_short_desc = hdnshortdesc.Value;
               mac_long_desc = hdnlongdesc.Value;
               mac_unit = 0;
               mac_rate =double.Parse(hdnrate.Value);
               FromDate = hdnmac_effdate.Value;
               string[] datesplit = FromDate.Split('-');
               mac_rate_eff_date = datesplit[2] + "-" + datesplit[1] + "-" + datesplit[0];

               //if(datesplit[0].Length==4)
               //{
               //    mac_rate_eff_date = datesplit[0] + "-" + datesplit[1] + "-" + datesplit[2];
               //}

           }
           if (tabname == "ItemOfMachinery")
           {
               if (dbwork == "delete")
               {
                   mac_id = Convert.ToInt32(hdnmac_id.Value);
                   mac_rate_id = int.Parse(hdnmac_rate_id.Value);
               }
               else
               {
                   //imc_id = int.Parse(hdnworkid.Value);
                   //icode = hdncategorycode.Value;
                   //icatname = hdncategoryname.Value;
               }
           }

推荐答案

我认为您的日期时间格式不正确。请使用支持的格式,例如



I think your datetime format is not correct. Please make it as supported format like

ToString("yyyy/MM/dd")





请参阅以下链接

http://www.csharp-examples.net/string -format-datetime / [ ^ ]



如果您的第一行没有出现错误,那么请具体说明发生了哪一行错误?

or

see the link below
http://www.csharp-examples.net/string-format-datetime/[^]

If the error is not occur on your first line then be specific about which line error occurred ?


这篇关于输入字符串未处于正确格式错误将在下面的代码中检查此正确的代码。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆