输入字符串的格式不正确。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.FormatException: 输入字符串的格式不正确。源错误: 执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。  堆栈跟踪: 
[FormatException: 输入字符串的格式不正确。]
   System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +0
   Lx.Sinaqd.Active.Admin.update_Click(Object Sender, DataGridCommandEventArgs e) +71
   System.Web.UI.WebControls.DataGrid.OnUpdateCommand(DataGridCommandEventArgs e) +109
   System.Web.UI.WebControls.DataGrid.OnBubbleEvent(Object source, EventArgs e) +507
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26
   System.Web.UI.WebControls.DataGridItem.OnBubbleEvent(Object source, EventArgs e) +100
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26
   System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +120
   System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +115
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +138
   System.Web.UI.Page.ProcessRequestMain() +1277 

解决方案 »

  1.   

    数据库字段类型和c#字段类型不是很一致
    在组合sql语句的时候,最好使用参数向sql command中传递参数,例如先声明connection和adapter

    string strSql ="";
    strSql = " update cec.TBL_ORDER;"
    strSql += " set PAYFLAG = '1' ";
    strSql += " ,UPDATEDATE = @UPDATEDATE ";
    strSql += " where ID = @ORDERID ";try
    {
    objAdapter = new SqlDataAdapter();
    objAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey; objAdapter.UpdateCommand = new SqlCommand(strSql,conn);  objAdapter.UpdateCommand.Parameters.Add("@ORDERID",SqlDbType.Int).Value = Convert.ToInt32(merchId); objAdapter.UpdateCommand.Parameters.Add("@UPDATEDATE",SqlDbType.DateTime).Value =DateTime.Now; objAdapter.UpdateCommand.ExecuteNonQuery();
     

    catch(Exception err)
    {
    ...这样不会出现数据库字段类型不匹配的错误
      

  2.   

    id = Convert.ToInt32(e.Item.Cells[0].Text.ToString());
      

  3.   

    把你这行代码打印出来看看
    "UPDATE Activity SET auditing='"+isPb+"',auditingcategory='"+import+"' WHERE ID='"+id+"'"或者你单步调试一下看哪句出错
      

  4.   

    没办法,只好试一下 killerwc(Elove^_^CS~B43) 的方法了.
      

  5.   

    不对啊,我把这一句删了,还出现同样的错误.
    MyDb.NonQuery("UPDATE Activity SET auditing='"+isPb+"',auditingcategory='"+import+"' WHERE ID='"+id+"'");
      

  6.   

    检查一下你的pageload函数内有什么不正常的代码。
      

  7.   

    那么看看你的这句
    id=Convert.ToInt32(e.Item.Cells[0].Text);
    这里可能转换有问题
    e.Item.Cells[0].Text
      

  8.   

    没有不正常的,只有
    LoadGrid();
      

  9.   

    id=Convert.ToInt32(e.Item.Cells[0].Text);
    这句也让我注掉了,直接让id=一个数了,可是还出现同样的问题.
      

  10.   

    那,就显示这些了.
    -------------------------------------------------------------
    输入字符串的格式不正确。 
    说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.FormatException: 输入字符串的格式不正确。源错误: 执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。  堆栈跟踪: 
    [FormatException: 输入字符串的格式不正确。]
       System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +0
       Lx.Sinaqd.Active.Admin.update_Click(Object Sender, DataGridCommandEventArgs e) +71
       System.Web.UI.WebControls.DataGrid.OnUpdateCommand(DataGridCommandEventArgs e) +109
       System.Web.UI.WebControls.DataGrid.OnBubbleEvent(Object source, EventArgs e) +507
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26
       System.Web.UI.WebControls.DataGridItem.OnBubbleEvent(Object source, EventArgs e) +100
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26
       System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +120
       System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +115
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +138
       System.Web.UI.Page.ProcessRequestMain() +1277--------------------------------------------------
      

  11.   

    终于知道错在哪了,
    id=Convert.ToInt32(e.Item.Cells[0].Text);
    CheckBox Pb=(CheckBox)e.Item.Cells[3].Controls[0];
    CheckBox Imp=(CheckBox)e.Item.Cells[4].Controls[0];
    这三行都不对,可应该怎么写呢?
      

  12.   

    哈,终天搞好了,
    id=Convert.ToInt32(e.Item.Cells[0].Text);
    CheckBox Pb=(CheckBox)e.Item.Cells[3].Controls[0];
    CheckBox Imp=(CheckBox)e.Item.Cells[4].Controls[0];就是这三行代码不对,全都有是索引的事,
    可是我还是不明白,为什么Controls[0];不行,改成Controls[1];就好了呢,可每个<editItemTeplate>里面只有一个checkbox啊.