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. C#
  4. DataView and DataGridTableStyle

DataView and DataGridTableStyle

Scheduled Pinned Locked Moved C#
cssxmlhelpquestion
1 Posts 1 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
    pokabot
    wrote on last edited by
    #1

    Hi im using a data view to populate my datagrid but am unable to use DataGridTableStyle. When populating my datagrid directly with a DataTable I set the DataGridTableStyle.MappingName to my DataTable name and am able to change the look of the table and columns without any trouble. When using the dataview i get no errors just a blank datagrid. Is it not possible to use the two together? Here is the code anyway, if someone could spot my mistakes it would be great! **Working Code** DataSet ds = new DataSet(); ds.ReadXml("xml.xml"); DataGrid dg = new DataGrid(); dg.DataSource = ds; dg.DataMember = "Players"; DataGridTableStyle dgts = new DataGridTableStyle(); dgts.MappingName = "Players"; dgts.RowHeadersVisible = false; dgts.PreferredRowHeight = 24; dg.TableStyles.Add(dgts); **Broken Code** DataSet ds = new DataSet(); ds.ReadXml("xml.xml"); DataView dv = new DataView(ds.Tables["Player"]); DataGrid dg = new DataGrid(); dg.DataSource = dv; //dg.DataMember = "Players"; **this line causes error** DataGridTableStyle dgts = new DataGridTableStyle(); dgts.MappingName = "Players"; dgts.RowHeadersVisible = false; dgts.PreferredRowHeight = 24; dg.TableStyles.Add(dgts); the broken code causes no errors just displays an empty grid (if i comment out the DataGridTableStyle code the grid dispalys just fine) Thanks in advance!!

    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