Search code examples
c#silverlightxamlriadomainservices

How do I select the right RadioButton from a list of them in a DataFrom EditTemplate based on a SQL row value?


I have a DataForm where I set the CurrentItem to an Entity returned from a LINQ RIA DataService. I am using Silverlight 4 with RIA services.

My "Current Item" is an Entity that a is row from SQL table. There's a column called "RestartType" on that table.

I have a DataForm where I set the DataForm.EditTemplate in the XAML.

I have three RadioButtons in my EditTemplate:

<RadioButton Content="Restart 1" /> <RadioButton Content="Restart 2" /> <RadioButton Content="Restart 3" />

How do I make it so IF the RestartType value is 0, then the Restart 1 radio button gets selected but the other ones don't get selected, or if the RestartType value is 1, then Restart 2 gets selected, and if it is 3 then Restart 3 gets selected and other radio buttons get de-selected.

I hope you can understand what I'm trying to do.

Thanks


Solution

  • I ended up using the ContentLoaded event handler in my DataForm then I got the CurrentItem of the DataForm as my object. I used DataForm.FindNameInContent to get the EditTemplate controls and set the right RadioButton checked appropriately.