Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Newbie: No defaults saving data using datagrid
Message
De
19/08/2008 18:15:11
Ed Milner
National Care Connection
Colorado, États-Unis
 
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Versions des environnements
Environment:
C# 2.0
OS:
Vista
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01340081
Message ID:
01340219
Vues:
11
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);
    }
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform