Note that there are some explanatory texts on larger screens.

plurals
  1. POasp.net gridview paging and sorting with linq to sql custom linq statement
    primarykey
    data
    text
    <p>Ok, I know this cant really be that hard, but im having trouble finding any info. I have a gridview on the page that i am filling with data based on a user selected date range(a dropdown list). When the user clicks the button i fill the gridview and display it. This is all done using Linq to Sql. I need to impliment paging and sorting as well. Help PLEASE!!! Below is my button click event... i am open to any suggestions to get this working</p> <pre><code>protected void btnGenerate_Click(object sender, EventArgs e) { int dateRange =0; if (rbDateList.Checked) { switch (ddlDateRange.SelectedIndex) { case 0: dateRange = 30; break; case 1: dateRange = 60; break; case 2: dateRange = 90; break; default: dateRange = 30; break; } } GYTDataContext gt = new GYTDataContext(); var productList = from o in gt.PurchaseOrderDetails join p in gt.Products on o.ProductId equals p.ProductId join h in gt.PurchaseOrderHeaders on o.PurchaseOrderId equals h.PurchaseOrderId where h.OrderDate&gt;DateTime.Now.AddDays(-dateRange) group o by o.ProductId into orderedItems select new { orderedItems.Key, QuantityOrdered = orderedItems.Sum(s =&gt; s.OrderQuantity) }; var totalOrderInfo = from p in productList join prod in gt.Products on p.Key equals prod.ProductId select new { prod.Reference, UnitPrice = prod.Price, prod.ManufacturerProductId, p.QuantityOrdered, TotalCost = prod.Price * Convert.ToInt32(p.QuantityOrdered) }; gvOrderReport.DataSource = totalOrderInfo; gvOrderReport.DataBind(); gvOrderReport.Visible = true; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload