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
100
OnInitializeDataSource and DataBind
posted

I have a situation where I need to do both of these but I'm having problems with it.  I'm using LoadOnDemand=XML so I need OnInitializeDataSource.

I have a button whose server side event changes some data, but since the OnInitializeDataSource event fires before the button's event the data that's sent to the client is already old.  So what I tried to do was set the datasource property and call DataBind.  What ends up happening is I get blank columns where the data normally is.  I also tried calling OnInitializeDataSource instead of DataBind but the data was still old.

 How can I get it to do what I want?

void MyGrid_InitializeDataSource(object sender, Infragistics.WebUI.UltraWebGrid.UltraGridEventArgs e)
{
MyGrid.DataSource = GetData();
}

private void btnAdd_ServerClick(object sender, System.EventArgs e)
{
// Change the data
RenameItems();
MyGrid.DataSource = GetData();
MyGrid.DataBind();
}

Parents
No Data
Reply
  • 100
    Verified Answer
    posted

    Figured out my problem.

    I can call ResetRows() before setting the DataSource and calling DataBind() and everything seems to work as expected.  If there's a better way please let me know!

     private void btnAdd_ServerClick(object sender, System.EventArgs e)
    {
    // Change the data
    RenameItems();
    MyGrid.ResetRows();

    MyGrid.DataSource = GetData();
    MyGrid.DataBind();
    }

Children
No Data