I'm trying to subclass the .NET 2.0 Gridview control and implement a custom Update to perform when "edit" is clicked; however I get the following cryptic error message: "An unexpected error has occurred." I'm trying to access our db logs to see if its failing there, but until i get access, i cannot debug the issue. Here are snippets of my code:
In the WebPart CreateChildControls method:
sqlDataSource.UpdateCommand = "dbo.UpdateInvoiceData";
sqlDataSource.UpdateCommandType = SqlDataSourceCommandType.StoredProcedure;
sqlDataSource.UpdateParameters.Add(new Parameter("month", DbType.Int32, "2"));
sqlDataSource.UpdateParameters.Add(new Parameter("year", DbType.Int32, "2010"));
this.Controls.Add(sqlDataSource);
EditGridView edv = new EditGridView(sqlDataSource);
this.Controls.Add(edv);
In the EditGridView webcontrol:
OnLoad:
this.AutoGenerateEditButton = true;
this.AutoGenerateColumns = true;
string[] keyNames = { "Name" };
this.DataKeyNames = keyNames;
this.EnableViewState = true;
this.DataSourceID = sqlDataSource.ID;
this.DataBind();
protected override void OnRowUpdating(GridViewUpdateEventArgs e)
{
   try
   {
      sqlDataSource.UpdateParameters.Add(new Parameter("ExtraParamName", DbType.Int32, e.NewValues["ExtraParamName"].ToString()));
      sqlDataSource.UpdateParameters.Add(new Parameter("Name", DbType.String, e.NewValues["Name"].开发者_开发问答ToString()));
      sqlDataSource.UpdateParameters.Add(new Parameter("spUser", DbType.String, "test"));
    }
    catch (Exception ex)
    {
       this.Page.Response.Write("Error occurred while updating the record.  " + ex.Message);
    }
}
This line:
...("ExtraParamName", DbType.Int32, e.NewValues["ExtraParamName"].ToString()));
You are saying the type is an int but you are passing it a string (name). Is that right?
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论