views:

133

answers:

2

What suggestions do people have for a timeslot data structure?

I have a number of activities and I'm planning to display them in a datagrid with days as columns and timeslots as rows. This suggests to me a timeslot data structure with 5 properties for the five days (the columns) for every value I want to use e.g. a timeslot ID and the number of slots left.

So...

  • Property Day1ID
  • Property Day1Slots
  • Property Day2ID
  • Property Day2Slots
  • Property Day3ID
  • Property Day4Slots
  • etc

Then each TimeSlot structure would be for a specific time... say 9:00 and another for each hour after that. Then I'd have a list of timeslot structures that will auto bind against the datagrid.

I'm exporing new ground here and as you can see I'm not very clear on what/how to do it?

All suggestions welcome,

Thanks

A: 

I would not hard code the time slots and days. I would put them in a matrix. A matrix with e.g. 5 columns for the days and e.g. 24 rows for the timeslots.

Adam Smith
I'm not sure how I'd bind a datagrid or repeater against the matrix though, the idea was to make the data structure do all the work and not have to work through the matrix displaying the appropriate data, or have I missed your point?
David A Gibson
+1  A: 

Create a structure like this:

struct DayInfo
{
    int ID;
    int[] Slots;
}

and then have a List to store all your data, which can be easy binded to 2 nested repeaters.

M. Jahedbozorgan
I think I'll try this and resort to nested repeaters as you suggest - it is a complicated Data Structure that I want to a complicated UI is to be expected, thanks
David A Gibson