?
Solved

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

Posted on 2009-07-16
1
Medium Priority
?
383 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 2000 total points
ID: 24867953
DataView dv = dt.DefaultView
dv.Sort = "ColumnName DESC"
0

Featured Post

Docker-Compose to Simplify Multi-Container Builds

Our veteran DevOps Author takes you through how to build a multi-container environment, managed with a single utility in order to simplify your deployments.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

801 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