Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Newbie: No defaults saving data using datagrid
Message
From
19/08/2008 18:15:11
Ed Milner
National Care Connection
Colorado, United States
 
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Environment versions
Environment:
C# 2.0
OS:
Vista
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01340081
Message ID:
01340219
Views:
10
Thanks Bob and Tim,
I enabled 'BindOnPostBack' which caused a 'Invalid postback or callback argument' unhandled exception. This exception was stopped by adding 'EnableEventValidation="false" page property (not sure this is a good idea). But the record still not inserted.

Bob, yes I'm using a datagrid and yes save is being called " this.Save(this.oEditor, dsEditor); "
    protected void dgrdEditor_UpdateCommand(object source, DataGridCommandEventArgs e)
    {
        // Get the item to be updated
        this.dgrdEditor.EditItemIndex = e.Item.ItemIndex;

        // Retrieve the previous entity DataSet
        DataSet dsEditor = (DataSet)Session["dsEditor"];

        // Save the DataSet (the DataGrid automatically binds back)
        if (this.Save(this.oEditor, dsEditor) == mmSaveDataResult.RulesBroken)
        {
           this.lblErrorMsg.Text = this.oEditor.Rules.GetAllBrokenRules();
       }

        // Reset the edited item and rebind the DataGrid
        this.dgrdEditor.EditItemIndex = -1;
        this.BindControl(this.dgrdEditor);

    }
When adding a row to the datagrid, using the Jump start code, shouldn't the table defaults be present in the datagrid column?
    protected void btnAddEditor_Click(object sender, EventArgs e)
    {
        // Retrieve the previous entity DataSet
        DataSet dsEditor = (DataSet)Session["dsEditor"];

        // Add a new row to the DataSet
        this.oEditor.NewRow(dsEditor, this.oEditor.TableName, new TblEditorDefaults(1, 1));

        // Store the DataSet back into the session
        Session["dsEditor"] = dsEditor;

        // Set the new row for editing
        this.dgrdEditor.EditItemIndex = dsEditor.Tables[this.oEditor.TableName].Rows.Count - 1;

        // Rebind the GridView
        this.BindControl(this.dgrdEditor);
    }
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform