I am using northwind database and try to return product table using linq to sql. below pasted my code.
protected void Page_Load(object sender, EventArgs e)
{
DemoDataContext dbContext = new DemoDataContext();
var lyncQuery = from product in dbContext.Products
where product.CategoryID == 2
orderby product.UnitPrice descending
select product;
ProductDataGrid.DataSource = lyncQuery;
Response.Write(lyncQuery.ToString());
ProductDataGrid.DataBind();
}
}
i verified lyncquery returns all the columns by printing that in response.write, when i debug also i am seeing all the columns value in lyncquery but when i am binding that with datagrid i am seeing only productid, productname, discontinued,quantityperunit as below.
even i tried returning specific columns using below in select clause, select new { product.ProductID, product.ProductName, product.CategoryID, product.SupplierID, product.Discontinued, product.UnitPrice, product.QuantityPerUnit };
but still i am seeing only those 4 columns
any lead can help me in resolve this. Thanks in advance
Are you Autogenerating Columns in the GRIDVIEW or you have specified the columns to be shown in the gridview. There may be possibility that you are only displaying these 4 columns. Can you please Add your HTML page code also.