views:

933

answers:

1

Hi,

I got a datagrid in Silverlight. I would like

  • the datagrid (or usercontrol that contains the datagrid) to post to the server when the user edit a cell in the gird.

  • to signal to the datagrid using some symbol in the cell edited (like a loading-symbol) that a post is sent to the server and the control is waiting on a response.

  • to signal to the datagrid using colors (in the correct cell) if the update was successful.

I've figured out that I can use the WebClient class to make a call to the server in the objects (~cells) set-property but it feels like I do something fundamentally wrong then since:

  • I don't know in the set-property of the object which datagrid triggered the set-property

  • and since I don't know that I won't be able to figure out which datagrid (and which cell in the datagrid) to send back the response to (i.e. if the post was a success or failure).

I've also tried to observe some events in the datagrid (BeginningEdit, PreparingCellForEdit, SelectionChanged, CurrentCellChanged) but none of them give me the new value of the cell being edited.

Can anyone point me in the right direction on how to solve these problems?

+1  A: 

use DataBinding. Bind a collection of type ObservableCollection (where T is your object type) and when you return from the web client call, fill this collection. Since its observable, the data grid will see the new data.

Shawn Wildermuth