I am working on an employee-scheduling system. I think I have the database setup pretty well, and have run into a snag on pulling the data for my database and getting it onto the page. I am using LINQ to make things easy on myself.
Here is the Object Relational Map.
Here is my Linq select statement:
protected void LinqSelecting(object sender, LinqDataSourceSelectEventArgs e) {
MilhouseDataClassesDataContext mdb = new MilhouseDataClassesDataContext();
e.Result = from x in mdb.MilhouseHours
group x by x.HourString into hour
select new {
hourStr=hour.Key,
uName=hour};
}
Here are the pertinent parts of my GridView code:
<asp:GridView ID="GridView1" runat="server" DataSourceID="LinqDataSource1" AutoGenerateColumns="false">
<asp:TemplateField HeaderText="Sunday">
<ItemTemplate>
<asp:CheckBoxList ID="shiftsSun" runat="server" DataSource='<%#Eval("uName")%>' DataValueField="UserId" />
</ItemTemplate>
</asp:TemplateField>
...
</asp:Gridview>
This will correctly display the UserId from the database, but I want it to display the UserName. The only method I've gotten to have this display work is by changing my group statement to:
group x.aspnet_User by x.HourString into hour
I think I'm missing a big concept here. By using group, I should have access to the aspnet_user class members via the uName member of my anonymous class...or so I thought!
edit: Here are a couple screenshots of the variables captured while debugging.
My end goal is to have a gridview which will show a list of work shifts for x hour of y day in each cell. Any design or code help would be greatly appreciated. I can't seem to get my head around this.