I found the problem.
I started with the usual easy way by using Server Explorer and dragging a
table onto the page to autogenerate a GridView.
I then deleted the SqlDataSource and used my LINQ collection.
The problem with the quick and dirty startup is that it set
AutoGenerateColumns to false.
I needed to change this to True and it works.
<asp:GridView ID="GridViewStaff" runat="server" AllowPaging="False"
AllowSorting="True" AutoGenerateColumns="True"
Caption="PathWest Staff Phone List" CaptionAlign="Top"
CellPadding="4"
EmptyDataText="There are no data records to display."
onrowdeleting="GridViewStaff_RowDeleting" ForeColor="#333333"
GridLines="None" onload="GridViewStaff_Load" Visible="False">
<AlternatingRowStyle BackColor="White" />
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" ForeColor="White"
Font-Bold="True" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<PagerStyle ForeColor="White" HorizontalAlign="Center"
BackColor="#2461BF" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True"
ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView
Smacks self on head and pours another glass of virtual whiskey.
Now I just need to work out how to format the GridView using Dynamic data
rather than the easy static stuff.
Is there an easy way to do this?
Regards Peter Maddin
Applications Development Officer
PathWest Laboratory Medicine WA
Phone : +618 6396 4285 (Monday, Wednesday,Friday)
Phone : +618 9346 4372 (Tuesday, Thursday)
Mobile: 0423 540 825
E-Mail : [email protected]; [email protected]
The contents of this e-mail transmission outside of the WAGHS network are
intended solely for the named recipient's), may be confidential, and may be
privileged or otherwise protected from disclosure in the public interest.
The use, reproduction, disclosure or distribution of the contents of this
e-mail transmission by any person other than the named recipient(s) is
prohibited. If you are not a named recipient please notify the sender
immediately.
From: [email protected] [mailto:[email protected]]
On Behalf Of Greg Keogh
Sent: Friday, 16 March 2012 3:26 PM
To: 'ozDotNet'
Subject: RE: Learning LINQ
>I have a new project so I would thought here is an opportunity to embrace
LINQ, or in my case LINQ to SQL (at this stage).
Slightly askew to you question but ... don't forget you can also use Entity
Framework 4 instead of LINQ to SQL. Add an EDMX file to your project with
the defaults and bingo you can run LINQ queries against the context. I'm
finding EF4 very convenient these days, just for quick knock-ups or for
building more complicated services. I used netTiers and CodeSmith for many
years, but they're legacy for me know and I use EF4 for all new DB work.
I think EF4 has a better future than LINQ to SQL and is more scalable
(confirmation of this from anyone in-the-know would be reassuring).
-- Greg