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. Web Development
  3. ASP.NET
  4. dynamic bind GridView

dynamic bind GridView

Scheduled Pinned Locked Moved ASP.NET
questionlearning
4 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.
  • J Offline
    J Offline
    jason_mf
    wrote on last edited by
    #1

    I am a beginner. I want to bind part of fields from DataTable to GridView. data of the datatable from Three different "select". How do? Thanks.

    V S 2 Replies Last reply
    0
    • J jason_mf

      I am a beginner. I want to bind part of fields from DataTable to GridView. data of the datatable from Three different "select". How do? Thanks.

      V Offline
      V Offline
      vishalcodeproj
      wrote on last edited by
      #2

      public void binddata() { conn.Open(); OracleCommand cmd = new OracleCommand("SELECT * FROM EMP", conn); OracleDataReader odr = cmd.ExecuteReader(); dt1.TableName = "FXD"; dt1.Load(odr); ds.Tables.Add(dt1); GridView1.DataSource = ds.Tables["FXD"]; GridView1.DataBind(); conn.Close(); } in this way u can bind datatable to gridview..

      J 1 Reply Last reply
      0
      • J jason_mf

        I am a beginner. I want to bind part of fields from DataTable to GridView. data of the datatable from Three different "select". How do? Thanks.

        S Offline
        S Offline
        samMaster
        wrote on last edited by
        #3

        Hi, Use gridview BoundField like this: AccessibleHeaderText="string" ApplyFormatInEditMode="True|False" ConvertEmptyStringToNull="True|False" DataField="string" DataFormatString="string" FooterText="string" HeaderImageUrl="uri" HeaderText="string" HtmlEncode="True|False" InsertVisible="True|False" NullDisplayText="string" ReadOnly="True|False" ShowHeader="True|False" SortExpression="string" Visible="True|False> Set BoundFields then bound grid view with your data table such as previous reply shown.

        1 Reply Last reply
        0
        • V vishalcodeproj

          public void binddata() { conn.Open(); OracleCommand cmd = new OracleCommand("SELECT * FROM EMP", conn); OracleDataReader odr = cmd.ExecuteReader(); dt1.TableName = "FXD"; dt1.Load(odr); ds.Tables.Add(dt1); GridView1.DataSource = ds.Tables["FXD"]; GridView1.DataBind(); conn.Close(); } in this way u can bind datatable to gridview..

          J Offline
          J Offline
          jason_mf
          wrote on last edited by
          #4

          I only need to show them one or two Columns.

          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