when does webformdatagrid reflect changes to dataset???

L

Lore Leuneog

Hello

I' want to build a fully editable webformdatagrid. The cells have to be
textboxes all the time (this I already realised with columntemplates) and
the update for all changes has to be done by one Update-button which uses
the DataAdapter.Update Method.
Problem is: The DataSet does not seem to reflect the changes made in the
datagrid textbox-cells. Do I have to be in edit-mode to write changes to the
dataset? If yes, how can I do this without using the roweditbuttons because
I want to use my own table-edit button???

Thank you
Sincerely
Lore
 
N

Norman Yuan

You simply loop through each row (item) in the DataGrid in updatebutton
click event to , for example (pseudo code):

private void btnUpdate_Click(object sender, System,EventArgs e)
{
for (int i=0; i<myDataGrid.Items.Count; i++)
{
//Get a row in the DataGrid
DataGridItem item=myDataGrid.Items

TextBox txt;
//Get TextBix in the first cell, therefore you can get the value in
the textbox inputted by user,
txt=(TextBox)item.Cells[0].FindControls("txtFirst");

//Then get TextBox value in second cell,... You can use a "for" loop
the go through each text box in a row.

//After getting all values in all text box, update corresponding
DataRow in underline DataSet with these values
}

//Then Update DataSet to backend database if necessary.
}


HTH
 
L

Lore Leuneog

Thank you very much.

Your answer means also that it is normal that the dataset doesn't reflect
changes from the webdatagrid automatically - (which is very different to the
behavour of the windowsform datagrid) ???

Best regards
Lore





Norman Yuan said:
You simply loop through each row (item) in the DataGrid in updatebutton
click event to , for example (pseudo code):

private void btnUpdate_Click(object sender, System,EventArgs e)
{
for (int i=0; i<myDataGrid.Items.Count; i++)
{
file://Get a row in the DataGrid
DataGridItem item=myDataGrid.Items

TextBox txt;
file://Get TextBix in the first cell, therefore you can get the value in
the textbox inputted by user,
txt=(TextBox)item.Cells[0].FindControls("txtFirst");

file://Then get TextBox value in second cell,... You can use a "for" loop
the go through each text box in a row.

file://After getting all values in all text box, update corresponding
DataRow in underline DataSet with these values
}

file://Then Update DataSet to backend database if necessary.
}


HTH


Lore Leuneog said:
Hello

I' want to build a fully editable webformdatagrid. The cells have to be
textboxes all the time (this I already realised with columntemplates) and
the update for all changes has to be done by one Update-button which uses
the DataAdapter.Update Method.
Problem is: The DataSet does not seem to reflect the changes made in the
datagrid textbox-cells. Do I have to be in edit-mode to write changes to the
dataset? If yes, how can I do this without using the roweditbuttons because
I want to use my own table-edit button???

Thank you
Sincerely
Lore
 
N

Norman Yuan

Web app, by its nature is DISCONNECTED system, meaning, server sends a HTML
page to a client (browser) and then disconnects to the client (of course
there is smoe mechanism to maintain states between server and client). The
DataGrid is just a table rendered by browser on the client machine. Once the
page with DataGrid shows on browser, whatever user does with it, the server
does not know. So, it is you, the developer, who has to take the
resposibility to process changes made to the DataGrid when the page with
DataGrid is post back to the server.

Lore Leuneog said:
Thank you very much.

Your answer means also that it is normal that the dataset doesn't reflect
changes from the webdatagrid automatically - (which is very different to the
behavour of the windowsform datagrid) ???

Best regards
Lore





Norman Yuan said:
You simply loop through each row (item) in the DataGrid in updatebutton
click event to , for example (pseudo code):

private void btnUpdate_Click(object sender, System,EventArgs e)
{
for (int i=0; i<myDataGrid.Items.Count; i++)
{
file://Get a row in the DataGrid
DataGridItem item=myDataGrid.Items

TextBox txt;
file://Get TextBix in the first cell, therefore you can get the value in
the textbox inputted by user,
txt=(TextBox)item.Cells[0].FindControls("txtFirst");

file://Then get TextBox value in second cell,... You can use a "for" loop
the go through each text box in a row.

file://After getting all values in all text box, update corresponding
DataRow in underline DataSet with these values
}

file://Then Update DataSet to backend database if necessary.
}


HTH


Lore Leuneog said:
Hello

I' want to build a fully editable webformdatagrid. The cells have to be
textboxes all the time (this I already realised with columntemplates) and
the update for all changes has to be done by one Update-button which uses
the DataAdapter.Update Method.
Problem is: The DataSet does not seem to reflect the changes made in the
datagrid textbox-cells. Do I have to be in edit-mode to write changes
to
the
dataset? If yes, how can I do this without using the roweditbuttons because
I want to use my own table-edit button???

Thank you
Sincerely
Lore

 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top