Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Add rows from grid and otherwise (Web) -- urgent
Message
 
À
11/10/2004 00:46:57
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
00896357
Message ID:
00950547
Vues:
17
Mark,

> Here's my code that adds the new row: This doesn't generate an error, but the new row doesn't get the OrderID value I passed.

> private void btnNew_Click(object sender, System.EventArgs e)
> {
> // Retrieve the previous Order Detail DataSet
> DataSet dsOrderDetail = (DataSet)Session["dsOrderDetail"];
> // Add a new row to the DataSet
> this.oOrderDetail.NewRow(dsOrderDetail, this.oOrderDetail.TableName,
> new OrderDetailDefaultValues(this.OrderID));
> // Store the DataSet back into the session
> Session["dsOrderDetail"] = dsOrderDetail;
> // Set the new row for editing
> this.grdOrderDetail.EditItemIndex = dsOrderDetail.Tables[oOrderDetail.TableName].Rows.Count-1;
> // Rebind the DataGrid
> this.BindControl(this.grdOrderDetail);
> }

Right...I've changed the code in the Dev Guide as you listed above. You need one additional step for the default values to work properly. I'm not sure if this step is your current version of the Dev Guide Jump Start, but you need to put the following code in the OrderDetail business object's Hook
/// <summary>
/// Set any default values specified in the Default Value object
/// </summary>
/// <param name="dataRow">DataRow being added</param>
protected override void HookSetDefaultValues(DataRow dataRow)
{
	if (this.DefaultValues != null)
	{
		OrderDetailDefaultValues Defaults = (OrderDetailDefaultValues)this.DefaultValues;
		dataRow["OrderID"] = Defaults.OrderID;
	}
}
Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform