ASP.NET - I want to rebind gridview with datatable

Asked By bhanupratap singh on 24-Sep-12 07:48 AM
I have gridview with bound field columns. User insert data into gridivew. The problem is that if user need to modify/edit the record which have been inserted into database. For this i need to retrive data from database according to user input  and bind it to that very gridview through which gridview data is inserted into database. How to do this.
Hemanth Kumar replied to bhanupratap singh on 24-Sep-12 08:22 AM
Bhanu ,

 Try to seperate the Code to load the GridView in a Seperate Method .After Modifying the Data  in the GridView again call the same method .So that you will get the Updated data also in your grid.
Jitendra Faye replied to bhanupratap singh on 25-Sep-12 12:20 AM
For this create one method for loading data to grid and after each operation call this method to load record.
Annie Calvert replied to bhanupratap singh on 25-Sep-12 12:51 AM
    DataTable dt = Gridview.Datasource    will not work once the post back happens. The data source will be null once afte the post back. Anyother ideas ???
Use State management techniques to preserve the data. Sessions would be a good idea to implement. Ideal way for sorting and postback scenarios.