Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DataGrid Question
Message
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
00804904
Message ID:
00805386
Vues:
29
>If I'm using mmDataGrid to display child records, and I have AddRowsWithDownArrow = true, it doesn't automatically populate the parent foreign key field (as it does when I call NewRow() directly).
>
>Should it do this? And if not, where's the best place to hook into for getting this field populated (and any other defaults I might have).
>

If you set up the DefaultValue for your DataColumn it looks like it honors those. That won't help you if you have a DataRelation between your tables. Here is how to hook into the event that fires when you down arrow in the datagrid. You must be databound to the DefaultView (grid.BindingSourceMember=BizObj.DefaultView)
// hook into new row, do this after you retrieve data
DataView dv = det.GetCurrentDataSet().Tables["OrderDetail"].DefaultView;
dv.ListChanged += new ListChangedEventHandler(det_ListChanged);
Then in the event handler
private void det_ListChanged(Object sender, ListChangedEventArgs e)
{
	if (e.ListChangedType == ListChangedType.ItemAdded)
	{
		DataRowView drv = ((DataView)sender)[e.NewIndex];
		if (drv.IsNew)
		{ // Add any defaults here
			drv["iqty"] = 1;
			//You would have to do a table lookup here
			drv["cdesc"] = "ItemDescription";
		}
	}
}
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform