Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
995
How to do a simple update, no sample found
posted

Hello ,

I looked through all the the documentation and help and cannot find a sample on how to update my webgrid automatically with sqldatasource.
On your sample page it shows: "With ASP.NET 2.0 DataSource Controls such as the SqlDataSourceControl, the WebGrid can provide automatic updating - no code required". but there is no sample anywhere of that.
I have seen in the documentation updateDBrow but no sample was found for that.

So please let me know how to use webgrid and the sqldatasource to automatically update my grid.

Thanks
ARno

Parents
  • 19308
    posted

    It should "just work" but in my experience I always forget to do the following (and get yelled at when I write it up as a bug).

    Set the

    grid.DataKeyField = primarykeycolumn

    and optionally set

    grid.Bands[0].BaseTableName=table

    Also, when you create your SqlDataSource be sure to click on Advanced and choose to generate insert update and delete queries. That should be all there is to it.

    Now, to get the update to happen you can either postback the entire page, or add an empty UpdateRow event handler (with grid's ajax enabled) and the data will be updated each time the user leaves a row.

    Hope this helps,

    -Tony

     

Reply Children