Solved

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

Posted on 2009-07-16
1
382 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

691 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