protected void Button_Save_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    Tab_ProductEnti productenti = new Tab_ProductEnti();
                    productenti.ProductTitle = this.txtproductTitle.Text;
                    productenti.DefaultPic = this.txtDefaultPic.Text;
                    int parentID = int.Parse(this.hfParent.Value.ToString());
                    productenti.NumberID = this.txtnumberid.Text;
                    if (parentID == 0)
                    {
                        PageInfo("请选择商标类型再添加内容", "Product_Add.aspx");
                        return;
                    }
                    productenti.ParentID = parentID;
                    productenti.OrderID = int.Parse(txtorderid.Text.Trim());
                    productenti.KeyWord = txtkeyword.Text;
                    productenti.Content = this.FCKeditor1.Value;
                    productenti.Price = int.Parse(this.txtprice.Text);
                    productenti.Description = this.txtDescription.Text;
                    productenti.AddTime = DateTime.Now;
                    productenti.BeginTime = DateTime.Parse(txtbegintime.Text);
                    productenti.IsPass = ckIsPass.Checked;
                    productenti.IsRed = isred.Checked;
                    productenti.IsSpe = isspe.Checked;
                    productenti.Itsown = itsown.Checked;
                    productenti.BrandID = int.Parse(lanmu.SelectedValue);                    if (((Button)sender).Text == "保存")
                    {
                        string savePath = "Product/" + GetClassDirectory(parentID.ToString()) + "/" + DirFile.GetDateDir() + "/";
                        string fileName = DirFile.GetDateFile();
                        string fileEXName = ".html";
                        productenti.SavePath = savePath;
                        productenti.FileName = fileName;
                        productenti.FileExName = fileEXName;
                        if (Tab_Product.Add(productenti) == 1)
                        {
                            CreateHmtl(productenti);
                            PageInfo("添加成功", "Product_List.aspx");
                        }
                        else
                        {
                            PageInfo("添加失败", "Product_Add.aspx");
                        }
                    }
                    else if (((Button)sender).Text == "保存修改")
                    {
                        string ID = Request.QueryString["ID"];
                        productenti.SavePath = ViewState["SavePath"].ToString();
                        productenti.FileName = ViewState["FileName"].ToString();
                        productenti.FileExName = ViewState["FileExName"].ToString();
                        if (ID == null || ID.Equals(""))
                        {
                            PageInfo("参数错误", "Product_List.aspx");
                        }
                        else
                        {
                            productenti.ID = int.Parse(ID);
                            if (Tab_Product.Edit(productenti) == 1)
                            {
                                CreateHmtl(productenti);
                                PageInfo("修改成功", "Product_List.aspx");
                            }
                            else
                            {
                                PageInfo("修改失败", "Product_List.aspx");
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    log.Error(ex.Message);
                }
            }
        }

解决方案 »

  1.   

    int.Parse DateTime.Parse 很危险啊
      

  2.   

    到最后
    catch (Exception ex)
      {
      log.Error(ex.Message);
      }
    ex这个地方报错
      

  3.   

    log.Error(ex.Message);
    换成
    log.Error(ex.ToString());
      

  4.   

    int.Parse DateTime.Parse这个地方有什么问题不?
      

  5.   

    this.hfParent.Value
    txtorderid.Text
    this.txtprice
    txtbegintime.Text
    lanmu.SelectedValue
    ID
    出错时你检查下上面这些的值分别是什么,贴上来最好
      

  6.   

    log.Error(ex.Message);
    换成
    log.Error(ex.ToString());
    也还是不行
      

  7.   

    一步步执行,看看是那句代码报错,然后跳到错误catch中了
    你代码中确实用了很多 Parse 相关的,这个你要不做判断,最有可能出错的就是他,当数据不能被转换为目标类型是就会出错了
      

  8.   

    this.hfParent.Value=1
    txtorderid.Text=999
    this.txtprice=1800
    txtbegintime.Text=2006-12-8 0:00:00
    lanmu.SelectedValu  没有获取到值
      

  9.   

    这段代码没有执行就直接跳到catch里面,上面的代码没有报错
    if (((Button)sender).Text == "保存")
                        {
                            string savePath = "Product/" + GetClassDirectory(parentID.ToString()) + "/" + DirFile.GetDateDir() + "/";
                            string fileName = DirFile.GetDateFile();
                            string fileEXName = ".html";
                            productenti.SavePath = savePath;
                            productenti.FileName = fileName;
                            productenti.FileExName = fileEXName;
                            if (Tab_Product.Add(productenti) == 1)
                            {
                                CreateHmtl(productenti);
                                PageInfo("添加成功", "Product_List.aspx");
                            }
                            else
                            {
                                PageInfo("添加失败", "Product_Add.aspx");
                            }
                        }
                        else if (((Button)sender).Text == "保存修改")
                        {
                            string ID = Request.QueryString["ID"];
                            productenti.SavePath = ViewState["SavePath"].ToString();
                            productenti.FileName = ViewState["FileName"].ToString();
                            productenti.FileExName = ViewState["FileExName"].ToString();
                            if (ID == null || ID.Equals(""))
                            {
                                PageInfo("参数错误", "Product_List.aspx");
                            }
                            else
                            {
                                productenti.ID = int.Parse(ID);
                                if (Tab_Product.Edit(productenti) == 1)
                                {
                                    CreateHmtl(productenti);
                                    PageInfo("修改成功", "Product_List.aspx");
                                }
                                else
                                {
                                    PageInfo("修改失败", "Product_List.aspx");
                                }
                            }
                        }
      

  10.   

    你先把方法里的 try catch 去掉,然后再调试,等到报错,看出在哪行上