calvin Posted September 8, 2004 Posted September 8, 2004 Hi, I do a textbox to collect data and binding to datagrid(use arraylist to hold data). When user click the submit button, all the data in arraylist will be add to database. Then, if I try to add data to datagrid, the previous "record" still remain in datagrid. I would like to know how to clear the datagrid. Is anyknow could give me some idea and help will more appreciate. Calvin :) Quote
tate Posted September 8, 2004 Posted September 8, 2004 Did you try clearing the array that is bound to the datagrid as part of the submit event? Quote
calvin Posted September 9, 2004 Author Posted September 9, 2004 How to refresh(clear) datagrid binding with DataTable? Problem has been solved, the approach on the below will refresh the arraylist. DataGrid1.DataSource = (New ArrayList) DataGrid1.DataBind() But how about refreshing the DataTable binding to datagrid? Any idea? Calvin :) Quote
tate Posted September 9, 2004 Posted September 9, 2004 If I understand correctly the data entered within a text box is used to increment an array list which also fills the datagrid. When all of the required data is entered, as validated by the datagrid content, the OnClick event of the submit button is used to update some database. Therefore, there is 2 unique things going on. I don't understand what you mean by DataTable. I would try to approach the OnClick event like; Define database connection Define data adapter Define dataset Use the fill method of the adapter to populate dataset Create CommandBuilder object Define a new row based on the data in the array Use the update method of the adapter to add new record to database Quote
calvin Posted September 9, 2004 Author Posted September 9, 2004 Problem solved I got my solution already, thanks for your help. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.