How to synchronise, grid and dataset update ???

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Dear all,

I have a strange behaviour when updating a grid. I will try to explain
clearly:

I have a CustDataSet object fill with customer information like Name,
Firstname, Country, adress
That Custdataset contains all my customer information. Then I have a web
page on which my user can select only customers from a particular country.

For that i create a Dataview object from CustDataset. I set the RowFilter to
get only the desired country. Then I bind that DataView to my DataGrid.
If CustDataset contains information from that country, then they get
properly displayed in the grid.

At this stage, my user is able to edit records from that dataGrid bind to
DataView or Add a new entry.
For edition an Edit, Upadate template column has been added and in the
EditCommand event I have following code :

dgLabData.EditItemIndex = e.Item.ItemIndex
dgLabData.DataSource = dataView
dgLabData.DataBind()

Then my user gets text box field to update data directly from grid. When
pressing the Updade link, current records need to be update and store in
custDataset.

In the grid UpdateCommand I retrive cells value as follow:
newData(0) = CType(e.Item.Cells(1).Controls(0), TextBox).Text
newData(1) = CType(e.Item.Cells(2).Controls(0), TextBox).Text
newData(2) = CType(e.Item.Cells(3).Controls(0), TextBox).Text

dgLabData.EditItemIndex() = -1
dgLabData.DataSource = dataview
dgLabData.DataBind()

After this I did not get display any changes made, or new row added but
always the previous initial state.

How to synchrosise changes made in the dataGrid, dataview, dataset object in
order that it reflect changes when DataBind is called ??

I am lost, thnaks for your help

serge
 
You need to create a new data row, populate the values you read in it, add the row to the datatable, call the dataset AcceptChanges method, and after all this is done call the datagrid Bind()
 
Back
Top