update databound DataGrid ?


Well-known member
Feb 2, 2013
Programming Experience
I have searched Google for an answer but have had NO luck finding an answer to this question.

I would like to update a DataGrid which is databound to a database....I have a page that creates a new Invoice..and the user can add items to the invoice ,,so when the user adds a item I create a list<Item> the Item has properties like name, description, price, quantity etc. etc. I add the item to the list everytime the user clicks the add item button....I would like to update the datagrid with each new item added...I could add the item to the database then update the page but if the user decides to cancel the invoice then I would have to delete the items added..I think it would be easier to keep it this way...but not sure if I can update the gridview because it is databound......?

Firstly, is it a DataGrid or a GridView? You say the former up until the last sentence, then you say the latter.

Regardless, I think what you need to do is make an AJAX call to update the data source and thus update the grid. I don't use Web Forms so I'm not well up on how AJAX is used but, from what I do know, I would expect that you'd have to put the grid inside an UpdatePanel.
Ahhh...damn sorry about that , it is a GridView...I will try what you suggest with a UpdatePanel...Thank You!

Top Bottom