This is a migrated thread and some comments may be shown as answers.

Basic Databinding Question

2 Answers 73 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 06 Aug 2008, 08:18 PM
I have a RadGrid being bound to an in-memory dataset which I persist between request.

A user can edit a row in the grid, and I handle the UpdateCommand event. In this event I'm trying to get the changed values, so I do:

Dictionary<string, object> newValues = new Dictionary<string, object>();
GridEditableItem gridItem = e.Item as GridEditableItem;
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, gridItem);

This code works fine if I bind the data to the dataset in Page_LoadCompleted, but these values will all be blank of I bind the to the dataset in Page_Load.

This makes sense, as Page_LoadCompleted happens after the page events are processed. So in order for me to get the changed values in the grid, I have to make sure I don't bind the dataset to the RadGrid before I've handled page events.

This presents me with a problem. I also have a button that allows users to perform an action which changes the display of the row. I do this by handling the ItemCommand and doing something like:

e.Item.BackColor = System.Color.Red;

This won't work if I'm databinding the grid in Page_LoadCompleted since that will effectively "erase" the color change I made in the ItemCommand since the LoadCompleted event happens after the ItemCommand event.

So what's the best practice/solution here?

2 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 11 Aug 2008, 06:15 AM
Hello Robert,

Please use NeedDataSource to assign the grid DataSource manually. You can find more info in our help documentation.

Sincerely yours,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mike
Top achievements
Rank 1
answered on 09 Sep 2008, 08:04 PM
Try this

e.Item.ForeColor = System.Drawing.

Color.Red;

Tags
Grid
Asked by
Robert
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Mike
Top achievements
Rank 1
Share this question
or