Custom Datagrid

K

Kb

I have written custom data grid that has dataset stored in session as
its data source. The grid is always in edit mode so at any time users
can change the values in any grid rows. I have add row button on the
grid and want to save the changes to grid if add button is pressed.

I am trying find the best possible solution to read back the changes on
the grid to data source. If I don't read back values during data bind
original values will update the change.

Thanks in advance for any information/suggestion.
KB
 
D

Darren Kopp

Create a method that handles the saving of the items in the grid to the
datasource. This method can now be reused in whatever other contexts
you need (such as a save button or the add button). If your add row
button's onclick event you would do call SaveChanges() method (or
whatever your method is) and then add the row, then rebind the grid.

For clarity, i would pull the binding details into another method like
BindGrid(). Everytime you save or add, you will want to re-bind to
make sure the the most recent data is shown. You also want to make
sure you don't just call BindGrid() everytime on page load, as you will
not catch the changes. Call BindGrid() on first load (!IsPostBack),
after saving changes, and after adding a row.

HTH,
Darren Kopp
http://blog.secudocs.com
 
E

Elton Wang

Hi KB,



In my experience, unless traffic between web server and database server is
critical, I don't check if user really made any change to original data. I
just update database using submitted data. And if you use database data to
check data changed ot not, that also occupies traffic.



I'm not sure if it is about your question.



HTH
 
K

Kb

Darren, Elton, Thanks for your input. The solution seems to work on only
first level of custom grid on the second nesting it fails. The reason
that I am trying to create custom grid is the grid can contain same type
of grid and so on i.e. it can nest.
 
D

Darren Kopp

Never nested datagrid's that point to the same dataset, so i don't know
if i can help you.

-Darren
 

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

Staff online

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top