Hi,
Can anyone tell me how to refresh a grid which is being populated by using InitializeDataSource?
I've used LoadOnDemand="xml" and trying to bind my grid in a method which I am calling in InitializeDataSource. But, when some action is taken on the screen, I need to refresh the grid for which I tried calling my method to bind the grid again. It's not working. I even tried explicity calling InitializeDataSource which didn't work.
I really need the refresh feature to work according to the requirements. Can someone please help me with some ideas here?
Thanks,
Kala
grid.clear before resetting the datasource seems to do the trick.
I used gridName.Reset(gridDatasource) and it seems do the trick.
Just to clarify, the DataSourceID is set in the front-end code for the UltraWebGrid. I guess resetting it in the code-behind is what causes the grid to refresh.
I was able to get my grid to refresh/databind using the following code:
protected void btnAddNewRow_OnClick(object sender, EventArgs e){ SQLDataSource1.Insert(); UltraWebGrid1.DataSourceID = SQLDataSource1.ID.ToString();}
When the button is clicked, the row inserts into SQL and then the grid refreshes and shows the new row. The second line of code in the function is what forces the grid to refresh. I hope this works for you like it worked for me. I am not 100% why it worked, but it has been deployed for 2 days and there have been no complaints so far.
Thanks,Wendi
Here is the update I got today from the supprot team:
You can do like below code snippet.
UltraWebGrid1.DataSource=null;UltraWebGrid1.DataBind();
UltraWebGrid1.DataSource= ShowAssignedFunds();UltraWebGrid1.DataBind();
***
It didn't help. I've mailed them back that this solution is not working. Please check out my mail below in detail:
*****
I am unable to refresh the grid this way. I am getting "Failed to compare two elements in the array" error when trying to use Databind the second time. To overcome this, I tried the following two steps which didn't help:
Step1: (in InitializeLayout that occurs after Databind)
e.Layout.Bands[0].Columns.FromKey("Role").IsGroupByColumn = false;e.Layout.ViewType = ViewType.OutlookGroupBy;e.Layout.Bands[0].Columns.FromKey("Role").IsGroupByColumn = true;
Step2: (before even assigning the datasource)
gridFundToAssign.DisplayLayout.Bands[0].SortedColumns.Clear();gridFundToAssign.PerformGroupRows();gridFundToAssign.DisplayLayout.Bands[0].Columns.Clear();gridFundToAssign.Clear();gridFundToAssign.ResetBands();gridFundToAssign.ResetColumns();gridFundToAssign.ResetRows();
Please let me know a solution.
Also, I feel that the InitializeDatasource is making this page very slow. It's getting called on initial page load and then my serverside functions and then rebinding the grid. Instead of giving the speed required with xml features that I tried to use here, looks like the page performance is degraded.