Web App - Datagrid - Refreshing

Hi,

      I have a datagrid on a form with controls to allow the adding of a new record to the database.  The adding process works fine, except that after I click the Save button, the grid doesn't reflect the new item (if it's on the same page currently shown) unless I flip pages in the datagrid away from and back to that page.  I want to make the grid automatically update itself to show the new record.  Here's my code:


            DS_UserSetup1.AcceptChanges()

        SqlDataAdapter1.Fill(DS_UserSetup1)
        DBGrid1.DataSource = DS_UserSetup1
        DBGrid1.DataBind()

     So once the new record is saved to the database, then the dataset is told to accept the changes.  Afterwards, I refill the dataset, reset the datasource for the grid and tell it to bind again.  But this apparently doesn't make the control refresh.  I still have to flip to the next page and then back in the datagrid to see the new record.

JP
gleznovAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rdrunnerCommented:
Is the Dataadapter configured to update the Dataset that he is updateing?

Well if you made the DA with a wizzard there is a checkbox that will return the current inserted/Updated row in case you update/Insert data?

Can you post the SQL That the DA is using for the Update?
0
gleznovAuthor Commented:
I'm not sure exactly what you're wanting - I used the drag-n-drop dataadapter, used the SQL statement mode, if I hit advanced options all three are checked, and if you want the text under properties in the UpdateCommand area, let me know.

JP
0
rdrunnerCommented:
Yes that text please :)

After reading my own response i must admit it sounds horrible :)
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

ahmadfuwadCommented:
'after entering the record clear the datset
DS_UserSetup1.clear()
then make a new instance
DS_UserSetup1=new dataset()
and then fill the data and bind it to the datagrid
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
123654789987Commented:
U have to use the Update method of the DataAdapter.

 Dim myConn As New OleDbConnection(myConnection)
    Dim myDataAdapter As New OleDbDataAdapter()
    myDataAdapter.SelectCommand = New OleDbCommand(mySelectQuery, myConn)
    Dim custCB As OleDbCommandBuilder = New OleDbCommandBuilder(myDataAdapter)

    myConn.Open()

    Dim custDS As DataSet = New DataSet
    myDataAdapter.Fill(custDS)

    ' Code to modify data in DataSet here

    ' Without the OleDbCommandBuilder this line would fail.
    myDataAdapter.Update(custDS)

    myConn.Close()

    CreateCmdsAndUpdate = custDS

Once u do this u can check whether the dataset has accepted the changes. Then u can use the
datagrid.Datasource = custDS.

U have to do all this within
if Not Page.IsPostback

End if
0
gleznovAuthor Commented:
Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.