Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Create a New Row in the DataDridView
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Create a New Row in the DataDridView
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01164909
Message ID:
01164909
Views:
59
Kelvin,

I am having problem getting the new row added to show up on the datagridview. If after creating a new record and type in all neccessary information of the new row, I do not have any problem saving.

I have a business object "Purchase" and a child business object "Purchase Detail". Using the maintenance form to create Master/Child form to maintain the information. For the "PurchaseDetail", I used a mmPicker to retrieve the "Product" from the the pick list to be inserted as a "PurchaseDetail" item. The Primary key for "Purchase" is "PurchaseID" and the for "PurchaseDetail" is "PurchaseID, ProductID". The DataGridView is bound to the "PurchaseDetail" object.

Here is the event callback for ItemSelected:

private void pckProductSearch_ItemSelected(object sender, mmPickerItemSelectedEventArgs e)
{
DataRow aNewRow = this.oPurchaseDetail.NewRow();
aNewRow[this.oPurchaseDetail.PrimaryKeys[0]] = this.oPurchase.Entity.PurchaseID;
aNewRow[this.oPurchaseDetail.PrimaryKeys[1]] = e.dsSelectedItems.Tables[0].Rows[0][this.oProduct.PrimaryKey];

this.grdPurchaseDetail.NavigateData(mmNavigate.Last);
this.grdPurchaseDetail.Focus();
}

The code assign the primary keys to the "PurchaseDetail" from "PurchaseID" from the "Purchase" object and "ProductID" from the selection of the picklist. All other columns in the new record is nullable and does not require any data.

After this method is called, I expected to see the new row appear in the datagridview, but I only see a blank row. Am I missing something here? Why does the DataGridView get updated to the dataset that it is bounded to.

Thanks and Have a Nice Day,
Peter Nguyen
Next
Reply
Map
View

Click here to load this message in the networking platform