Note that there are some explanatory texts on larger screens.

plurals
  1. POImplementing .NET Gridview with SqlDataSource - on edit exception
    primarykey
    data
    text
    <p>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:</p> <p>In the WebPart CreateChildControls method:</p> <pre><code>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); </code></pre> <p>In the EditGridView webcontrol:</p> <p>OnLoad:</p> <pre><code>this.AutoGenerateEditButton = true; this.AutoGenerateColumns = true; string[] keyNames = { "Name" }; this.DataKeyNames = keyNames; this.EnableViewState = true; this.DataSourceID = sqlDataSource.ID; this.DataBind(); </code></pre> <hr> <pre><code>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); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload