Solved

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

Posted on 2009-07-16
1
380 Views
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
 
try
        {
            string itemname;
            string itemid;
            if (this.ddltype.SelectedIndex == 0)
            {
                itemname = asbProduct.Text.ToString();
                itemid = asbProduct.SelectedValue.ToString();
            }
            else
            {
                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;
            dt.Rows.Add(dr);
 
            // Here i need to do the group by with the datatable 
            Session["ItemsToGrid"] = dt;        
            AddGridItems();
}

Open in new window

0
Comment
Question by:Rajeshk_cgm
1 Comment
 
LVL 9

Accepted Solution

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

Featured Post

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 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