Solved

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

Posted on 2009-07-16
1
376 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 earned 500 total points
ID: 24867953
DataView dv = dt.DefaultView
dv.Sort = "ColumnName DESC"
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now