Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4612044
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:21:01+00:00 2026-05-22T01:21:01+00:00

I have the following data model: Camp -> CampEvent <- Event. Camp has CampId

  • 0

I have the following data model:

Camp -> CampEvent <- Event.

Camp has CampId and Name associated with it.
Event has EventId, Name, Start/End (Dates).
CampEvent has (CampId,EventId)PK, CampId FK, EventId FK.

The tables are used to create a Domain Model and a Domain Service which is consumed from the client side on Silverlight.

I am successfully able to display the Event’s table in Silverlight using a grid.

The Grid has two template columns – one to display a checkbox, and another to display the name of the event.

So now the problem is somehow I need to check the checkboxes when this control goes in edit mode.

I’ve noticed that the Grid doesn’t have OnDataBound event, or it doesn’t have a way of setting the state of each checkbox to checked other than through binding.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T01:21:02+00:00Added an answer on May 22, 2026 at 1:21 am

    Well, apparently in Silverlight you don’t have the luxury of messing around with the contents of a GridViewRow. You can, however, achieve this by changing the underlying data source.

    In the above scenario we have a control which is used for creating an instance of Camp and associating it with one or many events. In a sense the control can either Create or Update a “Camp” object and its relationships with Events. The control state is controlled by an Enumeration public enum Mode { Create, Update }; and depending on which value this property has, the control will do either one, or both of the following binding binding operations:

    1. Get all event data and display it in a grid composed of rows having a checkbox & label.
    2. Check the boxes denoting the events in which a specific camp participates.

    This was all nice and dandy in theory but in principle I realized Silverlight needs a discrete data source to bind to. I created a collection of a CampEvent custom object in which every element has a boolean prperty IsChecked, along with the event name and event Id. The CampEvent object is not a Domain Entity object and is only used for binding.

    So to achieve my goal, these are the steps I took.

    1. Declare ObservableCollection where T is used for only binding. In this case the underlying data source for T is our Event, and a Linq to Entity query was used to grab the Id and the Name of the Event and transforms it into a CampEvent object with its IsChecked property set to false by default.

    2. If the Control is in Create mode I am done. The checkboxes in the Grid’s template column are two-way bound to the IsChecked property of the underlying data source. Step one is enough to create the default UI with all check boxes unchecked. Otherwise go to 3

    3. Well, number 2 was wrong, so therefore the control was in “Update” mode. If the SelectedCamp property of the control is set (and this property is of type Camp). At this point we create a Linq to Entitities query where we ask the domain service to Include the Events associated with the specified camp.

    4. Once the response from the query arrives, we iterate through every Event object that is associated with the camp. For every event that was received, we check to see if it exists in our ObservableCollection data source. If it does, we set the IsChecked property to true for that item. Once we data bind the grid, all events that are associated with a specific camp will be “Checked”.

    5. Mission accomplished.

    Few words on Database Structure, Domain Models generated by the Entity Framework, and WCF RIA.

    Well, as it turns out EF will get you maybe 80% there out of the box. The tool is not intelligent enough to know what a many-to-many relationship is. In the case with camp and events we have the following structure:

    camp -> participates in many -> events
    (many) events -> have many -> camps (as participants)
    

    So to make this happen we need a “joiner” table between camps and events. To do this properly, the joiner table should in theory have at the very least two columns:

    CampId -> Foreign Key
    EventId -> Foreign Key

    Now to create a primary key for the Table, we should have:

    CampId + EventId -> Composite Primary Key.

    Making our table have only 2 fields. Now this is super important because this relationship creates the Navigation property possible in EF.

    When the domain model is generated, the EF will not create the joiner table in the model. However to enable the navigation property between Camp and Event and vise versa there are a couple of things that have to happen on the underlying Domain Service meta data object.

    **1. Locate the Camp metadata info. Decorate the IEnumerble<Event>Events property with:

    [Include]
    [Association("CampEvent", "CampId", "EventId", IsForeignKey=True)]
    

    And to explain what those mean: The Include says whenever you query the domain model, please include every Event for the specified camp(s). The Association says there is an association table between camp and event for the navigation property to work. In the lookup table the camp has CampId identifier and Event has EventId. Use those to find all Events for the specified camp(s)**.

    2. Do the same for whatever other navigational properties you have.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following data model: I am writing a WCF service that needs
I have the following data: A post called Hello has categories greet Another post
We have the following data model: CalendarAppointment 1 <------> * AppointmentRole * <--------> 1
I have the following core data model with two entities: entity item which holds
Consider the following data model: Suppose I have a table called SuperAwesomeData where each
I have a domain data model which returns a class such as the following:
I have the following data: var data = [ { id: 1, name: 'Ed
Say I have the following ember-data model: App.Person = DS.Model.extend({ firstName: DS.attr('string'), lastName: DS.attr('string'),
I have the following setup for my Blog Data Model: Blog Articles Categories -----
I have the following models: class Product(models.Model): active = models.BooleanField(default=True) name = models.CharField(max_length=40, unique=True)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.