Order by in Session DataTable using linq / or some other method

Posted on 2009-07-16
Last Modified: 2013-11-11
hi i need to bind the gird values from session datatable(using order by)

thanks in advance..
public void ItemsToGrid()


        if (Session["ItemsToGrid"] == null)


            DataTable dt = new DataTable("ItemsToGrid");

            dt.Columns.Add(new DataColumn("ItemID", typeof(string)));

            dt.Columns.Add(new DataColumn("ItemName", typeof(string)));

            dt.Columns.Add(new DataColumn("UOM", typeof(string)));

            dt.Columns.Add(new DataColumn("Quantity", typeof(int)));

            Session["ItemsToGrid"] = dt;



in button click event am adding the rows into the Session datatable



            string itemname;

            string itemid;

            if (this.ddltype.SelectedIndex == 0)


                itemname = asbProduct.Text.ToString();

                itemid = asbProduct.SelectedValue.ToString();




                itemname = txtItemName.Text;

                itemid = "0";


            string UOM = txtUOM.Text;

            int quantity = Convert.ToInt32(txtquantity.Text.ToString().Trim());

            DataTable dt = new DataTable("ItemTable");

            dt = (DataTable)Session["ItemsToGrid"];

            DataRow dr;

            dr = dt.NewRow();

            dr["ItemID"] = itemid;

            dr["ItemName"] = itemname;

            dr["UOM"] = UOM;

            dr["Quantity"] = quantity;


            // Here i need to do the group by with the datatable 

            Session["ItemsToGrid"] = dt;        



Open in new window

Question by:Rajeshk_cgm
1 Comment

Accepted Solution

Rahul Goel earned 500 total points
ID: 24867953
DataView dv = dt.DefaultView
dv.Sort = "ColumnName DESC"

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Replace &lt; with < 14 54
SSL https .net web site force redirect 3 34
how to read json value 2 30
.NET tools for adding thread safety to a web app? 3 13
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now