Solved

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

Posted on 2009-07-16
1
379 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

776 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