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
80
How to update UltraWebGrid-data to DB after changing it programmatically
posted

Hi, I have a databound UltraWebGrid which updates values to the DB as it should. It does so when the user change a value in the grid and clicks a simple button for postback. However, I like to suggest some values to the user by changing the value by code, but when I do that - the data is not updated on postback. 

If the user changes another column on the same row that the code changes, only the user changed-column will be saved to the DB.

foreach (Infragistics.WebUI.UltraWebGrid.UltraGridRow udr in (UltraWebGrid1.Bands[0].Grid.Rows))
{
udr.Cells.FromKey(
"categoryid").Value = suggestcategoryid();
udr.Cells.FromKey(
"categoryid").DataChanged = true; // I tried with and without this DataChanged-properties
udr.DataChanged = Infragistics.WebUI.UltraWebGrid.DataChanged.Modified;
//UltraWebGrid1.UpdateDBRow(udr); // this updates the data to the database, but then the user never has the option to cancel
}

thanks

Parents
  • 45049
    Verified Answer
    posted

    WebGrid does not raise any events that you can listen to in response to the program changing data in server-side code; its update-related events (UpdateRow, DeleteRow, AddRow, UpdateCell, and their "batch" equivalents) respond to changes applied on the client.  Because of this, if you make a progrmamatic change to WebGrid cells in server-side code, it is up to you to also make the same change in your underlying data source.

    Since you're trying to programmatically suggest values, you might consider updating cells on the client instead.

Reply Children