Refresh of a seperate gridview in an ASP.NET page.
-
Hi All, I've been grappling with this for a few days now, and am no further forward, here's the scenario: I have a page that contains the following linqDataSource : productListDS (Selects * from products table) GridView : gridProductList (Data source is productListDS) linqDataSource : productDetailDS (Selects * from products table where id == id) DetailsView : detailsProduct (Data source is productDetailDS) The gridview lists all the products in the data source, with paging and select button enabled, when the select command is clicked the details view is then updated to show all the fields of the selected product and has the 'Edit', 'Insert' and 'Delete' commands enabled. The gridView ONLY shows 5 columns from it's data source (The AutoGenerateColumns option is false) and i'm constructing the colums manually in the columns tag. I have the DataKeys set to id, and when i click the select button everything works flawlessly. My problem comes when i do an Insert/Delete/Update. As an example if i add a new record by putting the details form into insert mode, fill in the fields and then click insert, it inserts the record into the underlying SQLServer database, but the gridview does not update. I've tried doing a 'gridProductList.DataBind()' in the page load, and in the details view 'ItemInserted' event, and still no luck. If however i browse away from the page, and then back the gridView then displays the newly added products. Even pressing F5 to force an update does not work, in fact all that achieves is to resubmit the last insert and add another new record to the DB. The linq Data SOurce is connected to a LInqToSql DBML class. Does anyone have ANY ideas on how to force the Grid View to update and show the table changes made using the details view without having to browse away from the page and then browse back. Cheers Shawty
-
Hi All, I've been grappling with this for a few days now, and am no further forward, here's the scenario: I have a page that contains the following linqDataSource : productListDS (Selects * from products table) GridView : gridProductList (Data source is productListDS) linqDataSource : productDetailDS (Selects * from products table where id == id) DetailsView : detailsProduct (Data source is productDetailDS) The gridview lists all the products in the data source, with paging and select button enabled, when the select command is clicked the details view is then updated to show all the fields of the selected product and has the 'Edit', 'Insert' and 'Delete' commands enabled. The gridView ONLY shows 5 columns from it's data source (The AutoGenerateColumns option is false) and i'm constructing the colums manually in the columns tag. I have the DataKeys set to id, and when i click the select button everything works flawlessly. My problem comes when i do an Insert/Delete/Update. As an example if i add a new record by putting the details form into insert mode, fill in the fields and then click insert, it inserts the record into the underlying SQLServer database, but the gridview does not update. I've tried doing a 'gridProductList.DataBind()' in the page load, and in the details view 'ItemInserted' event, and still no luck. If however i browse away from the page, and then back the gridView then displays the newly added products. Even pressing F5 to force an update does not work, in fact all that achieves is to resubmit the last insert and add another new record to the DB. The linq Data SOurce is connected to a LInqToSql DBML class. Does anyone have ANY ideas on how to force the Grid View to update and show the table changes made using the details view without having to browse away from the page and then browse back. Cheers Shawty
pingpingpong wrote:
I've tried doing a 'gridProductList.DataBind()' in the page load,
Page load runs before your events. So, you're binding before the insert. This is why browsing away and back works. Do your databinding in page prerender, always.
Christian Graus Driven to the arms of OSX by Vista.
-
pingpingpong wrote:
I've tried doing a 'gridProductList.DataBind()' in the page load,
Page load runs before your events. So, you're binding before the insert. This is why browsing away and back works. Do your databinding in page prerender, always.
Christian Graus Driven to the arms of OSX by Vista.
Thanks Christian, I'll look into that, one more question... Does ths even apply when i'm not doing the original databinding manually, i'm just letting the datasource/datagrid sort it out them selves. Calling the DataBind() proc just seemed like a sensible thing to try to force it to update.
-
pingpingpong wrote:
I've tried doing a 'gridProductList.DataBind()' in the page load,
Page load runs before your events. So, you're binding before the insert. This is why browsing away and back works. Do your databinding in page prerender, always.
Christian Graus Driven to the arms of OSX by Vista.