Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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 :)

Posted

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 :)

Posted

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

  • 3 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...