How to use Linq To Sql refer my below post
http://www.dotnetissues.com/2011/02/select-query-linq-to-sql-example.html
To Select ordered data from table below is the LINQ Query
Default3.aspx
http://www.dotnetissues.com/2011/02/select-query-linq-to-sql-example.html
To Select ordered data from table below is the LINQ Query
Default3.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server"/>
</div>
</form>
</body>
</html>
Default3.aspx.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataClassesDataContext db = new DataClassesDataContext();
var results = from o in db.Orders
where (o.iDelieveryTypeId == 1)
orderby o.iOrderNo descending
select new
{
o.iOrderNo,
o.sSenderName
};
GridView1.DataSource = results;
GridView1.DataBind();
}
}
No comments:
Post a Comment