Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. LINQ
  4. LINQ to dataview........

LINQ to dataview........

Scheduled Pinned Locked Moved LINQ
csharpdatabaselinqalgorithms
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pranavcool
    wrote on last edited by
    #1

    Hi, I have written a linq query and bind it to a gridview. Now i want to implement sorting on gridview columns for which i want this linq query to store in dataview. So how it is possible to store linq query in dataview. the following is the code which i have written to bind gridview.

        protected void BindGrid()
        {
            try
            {
                var employees = from e in DetailContext.Employees orderby 
                e.Emp\_Code descending 
                select new {e.Emp\_Id,e.Emp\_Code,e.F\_Name,e.L\_Name,e.Designation };
                GridView1.DataSource = employees;                
                GridView1.DataBind(); 
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }  
    

    Pranav Dave

    M 1 Reply Last reply
    0
    • P pranavcool

      Hi, I have written a linq query and bind it to a gridview. Now i want to implement sorting on gridview columns for which i want this linq query to store in dataview. So how it is possible to store linq query in dataview. the following is the code which i have written to bind gridview.

          protected void BindGrid()
          {
              try
              {
                  var employees = from e in DetailContext.Employees orderby 
                  e.Emp\_Code descending 
                  select new {e.Emp\_Id,e.Emp\_Code,e.F\_Name,e.L\_Name,e.Designation };
                  GridView1.DataSource = employees;                
                  GridView1.DataBind(); 
              }
              catch (Exception ex)
              {
                  throw ex;
              }
          }  
      

      Pranav Dave

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      As your starting point DetailContext.Employees is probably a class I think you are in trouble. If you use a datatable/viw as your starting point and AsEnumerable then you can cast the result as a dataview. I do that in this article[^] These look promising[^] but I'll bet they all start from tables

      Never underestimate the power of human stupidity RAH

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups