problem in displaying the data in datagrid`
-
Hi, I am mani. I have a problem in display the data in datagrid. What i did is I am creating a form and in this form i created a 6 textboxes and one search button. whenever the user enter a text in textbox i retrieve the data from the database and displayed in the datagrid. The problem is when the user again enter the text in text box the datagrid is filled with new data and last data will be lost. But i want that newly searching data should be displayed in datagrid including the last searching data. If anyone knows the way how it should be doing please rly me. and provide an example in maintaing a datatable session variable. regards, manikanta.
-
Hi, I am mani. I have a problem in display the data in datagrid. What i did is I am creating a form and in this form i created a 6 textboxes and one search button. whenever the user enter a text in textbox i retrieve the data from the database and displayed in the datagrid. The problem is when the user again enter the text in text box the datagrid is filled with new data and last data will be lost. But i want that newly searching data should be displayed in datagrid including the last searching data. If anyone knows the way how it should be doing please rly me. and provide an example in maintaing a datatable session variable. regards, manikanta.
This problem can be solved if u use datatable. The data that was present on the data grid just fill this data to datatable and then the new searched data will also be filled in the same datatable then bind this datatable to the grid so that the previous data will not be lost.
-
Hi, I am mani. I have a problem in display the data in datagrid. What i did is I am creating a form and in this form i created a 6 textboxes and one search button. whenever the user enter a text in textbox i retrieve the data from the database and displayed in the datagrid. The problem is when the user again enter the text in text box the datagrid is filled with new data and last data will be lost. But i want that newly searching data should be displayed in datagrid including the last searching data. If anyone knows the way how it should be doing please rly me. and provide an example in maintaing a datatable session variable. regards, manikanta.
Hi Mani, in your problem, u can save your last data in
datatable
variable. To use session variable,Session["mySearchResult"] = searchResultTable;
searchResultGridView.DataSource = searchResultTable;
searchResultGridView.DataBind();When u search new keyword and return data back from server, save it in temp table. then retrieve your previous saved table from Session. and Loop through every row again and add it into old table and re-save it to Session.
newSearchResultTable = // new search result data from server; searchResultTable = Session\["mySearchResult"\] as DataTable; // get back from session foreach(DataRow row in newSearchResultTable.Rows) // loop every rows { searchResultTable.Rows.Add(row); // add to existing table } Session\["mySearchResult"\] = searchResultTable; // save back and bind again searchResultGridView.DataSource = searchResultTable; searchResultGridView.DataBind();
Hint: when u enable the "
EnableViewState
" to false, your selected info will not be avaliable from the server. Hope it works,