I have finally solved my problem in a different way, Thanks.
But what advantages does LING offer over a classic Sqldata source query? LINQ query seems to be much less flexible than a classic Sqldata source query. For example you can make a public function out of a classic Sqldata source query to pass back results,
but not with LINQ query? What type can you declare for the result of a LINQ query function?
</div>
Please mark this post as "Answer" and earn a point.
thuhue
All-Star
15625 Points
3146 Posts
GridView Sorting with LING
Oct 08, 2009 01:37 AM|LINK
Given the following HTML and codebehind:
<form id="form1" runat="server">
<div>
<asp:GridView ID="Gridview1" runat="server" AutoGenerateColumns="False" BackColor="White"
BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Horizontal"
AllowSorting="true">
<RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
<Columns>
<asp:BoundField DataField="Ename" HeaderText="Employee Name" SortExpression="Ename" />
<asp:BoundField DataField="AnnSal" HeaderText="Annual Salary" DataFormatString="{0:c}"
SortExpression="AnnSal" />
</Columns>
<FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
<PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
<AlternatingRowStyle BackColor="#F7F7F7" />
</asp:GridView>
</div>
</form>
Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load
If Not IsPostBack Then
Dim query = From p In GetEmployeeList() Select p.Ename, AnnSal = (p.Sal * 12)
Me.Gridview1.DataSource = query
Me.Gridview1.DataBind()
End If
End Sub
The grid is populated OK but clicking on a field to sort generate this error:
The GridView 'Gridview1' fired event Sorting which wasn't handled.
How can event sorting handler be coded here?
Thanks for any help.
AGMAK
Member
326 Points
63 Posts
Re: GridView Sorting with LING
Oct 08, 2009 02:19 AM|LINK
Hi,
You have to add onsorting event handler, please see the below url
http://www.netomatix.com/development/GridViewSorting.aspx
Hope this helps
thuhue
All-Star
15625 Points
3146 Posts
Re: GridView Sorting with LING
Oct 08, 2009 04:49 PM|LINK
I have finally solved my problem in a different way, Thanks.
But what advantages does LING offer over a classic Sqldata source query? LINQ query seems to be much less flexible than a classic Sqldata source query. For example you can make a public function out of a classic Sqldata source query to pass back results, but not with LINQ query? What type can you declare for the result of a LINQ query function?
</div>Qin Dian Tan...
All-Star
113532 Points
12480 Posts
Microsoft
Re: GridView Sorting with LING
Oct 13, 2009 07:53 AM|LINK
Hi thuhue,
Read the following articles and posts you will know the advantages of Linq:
http://www.eggheadcafe.com/aspnet/how-to/146339/linqdatasource-vs-objectd.aspx
http://www.upsizing.co.uk/Art37_VSDataSources.aspx
http://forums.asp.net/t/1237037.aspx
http://forums.asp.net/t/1247864.aspx
Thanks,
If you have any feedback about my replies, please contactmsdnmg@microsoft.com.
Microsoft One Code Framework
thuhue
All-Star
15625 Points
3146 Posts
Re: GridView Sorting with LING
Oct 13, 2009 03:44 PM|LINK
Is the learning curve of LING steeper that its counterparts? Is there more to learn about LING than the rest?