Link to home
Start Free TrialLog in
Avatar of Rajeshk_cgm
Rajeshk_cgmFlag for India

asked on

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

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

ASKER CERTIFIED SOLUTION
Avatar of Rahul Goel
Rahul Goel
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial