• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 387
  • Last Modified:

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

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

1 Solution
Rahul Goel ITILSenior Consultant - DeloitteCommented:
DataView dv = dt.DefaultView
dv.Sort = "ColumnName DESC"
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now