Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Uppercasing column in grid before updating
Message
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01524049
Message ID:
01524060
Vues:
43
This is so not pretty, and I am sure it has to do with not understanding what and when MM.NET is doing binding in the background, but I just made this work with a monstrous kludge.

After the initial save back of the dataset from the grid when adding the record, I then use the index to point to the row in the dataset, uppercase the values in the dataset, then DO ANOTHER SAVE. When walking through with DEBUG, before the first save, the values in the new row are EMPTY, they do not even show the data that has been entereded into the added row on the grid.

The data is there on RETURN from the save, as entered.

At that point, I uppercased as shown. I also had to add the SetCurrentDataSet. Hmm.

On the second save pass, the uppercased values are saved.
        protected void grdCTInventoryGrid_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            // Get the item to be updated
            this.grdCTInventoryGrid.EditIndex = e.RowIndex;

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

            // Save the DataSet (the GridView automatically binds back)
            this.Save(this.oCTInventory, dsCTInventory);

            dsCTInventory.Tables["CtInventory"].Rows[e.RowIndex]["Inv_Code"] = (string)dsCTInventory.Tables["CtInventory"].Rows[e.RowIndex]["Inv_Code"].ToString().ToUpper();
            dsCTInventory.Tables["CtInventory"].Rows[e.RowIndex]["Inv_Group1"] = (string)dsCTInventory.Tables["CtInventory"].Rows[e.RowIndex]["Inv_Group1"].ToString().ToUpper();
            dsCTInventory.Tables["CtInventory"].Rows[e.RowIndex]["Inv_Group2"] = (string)dsCTInventory.Tables["CtInventory"].Rows[e.RowIndex]["Inv_Group2"].ToString().ToUpper();
            dsCTInventory.Tables["CtInventory"].Rows[e.RowIndex]["Inv_Descr"] = (string)dsCTInventory.Tables["CtInventory"].Rows[e.RowIndex]["Inv_Descr"].ToString().ToUpper();

            this.oCTInventory.SetCurrentDataSet(dsCTInventory);

            // Save the DataSet (the GridView automatically binds back)
            this.Save(this.oCTInventory, dsCTInventory);

            // Reset the edited item and rebind the GridView
            this.grdCTInventoryGrid.EditIndex = -1;
            this.BindControl(this.grdCTInventoryGrid);
        }
Ronald D. Edge
Retired from Indiana University Mar 1, 2011

"You've got to be very careful if you don't know where you are going,
because you might not get there."
“When you come to the fork in the road, take it.”
--Yogi Berra
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform