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 query to get all the records

Linq query to get all the records

Scheduled Pinned Locked Moved LINQ
csharpdatabaselinqquestion
3 Posts 3 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.
  • H Offline
    H Offline
    hahii
    wrote on last edited by
    #1

    Hi, I have a table named "Customers" which has 6 columns with 15 rows. I want to show all athe records in Gridview using linq quieries. I am using this query but it is not giving me all the records. How can I show all the records in Gridview. var type = (from p in entities.Customers select p) this.Gridview1.DataSource = type; this.GridView1.DataBind();

    I N 2 Replies Last reply
    0
    • H hahii

      Hi, I have a table named "Customers" which has 6 columns with 15 rows. I want to show all athe records in Gridview using linq quieries. I am using this query but it is not giving me all the records. How can I show all the records in Gridview. var type = (from p in entities.Customers select p) this.Gridview1.DataSource = type; this.GridView1.DataBind();

      I Offline
      I Offline
      Ian McCaul
      wrote on last edited by
      #2

      From what I can see there is nothing wrong with that statement. You should be getting all records. Are you sure the GridView isnt within a fixed height table/div? Once the gridview fills with rows it may be rolling off the bottom of the table/div and is basically being trimmed.

      1 Reply Last reply
      0
      • H hahii

        Hi, I have a table named "Customers" which has 6 columns with 15 rows. I want to show all athe records in Gridview using linq quieries. I am using this query but it is not giving me all the records. How can I show all the records in Gridview. var type = (from p in entities.Customers select p) this.Gridview1.DataSource = type; this.GridView1.DataBind();

        N Offline
        N Offline
        Niladri_Biswas
        wrote on last edited by
        #3

        Here is the answer to your question Everything is correct except that you need to type cast to the particular Entity before you r binding the source to your grid. e.g.

        public List<Customers> FetchRecord()
        {
        return( from p in entities.Customers select p )
        }

        this.Gridview1.DataSource = FetchRecord();
        this.GridView1.DataBind();

        Hope this helps :)

        Niladri Biswas

        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