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. regd dataset

regd dataset

Scheduled Pinned Locked Moved C#
questiondatabasexml
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.
  • K Offline
    K Offline
    karteek
    wrote on last edited by
    #1

    Hi, I have a dataset object and I am filling it with the rows of a table.Now I assigned it to a datagrid object.I don't know the schema of the table.Now I want the schema of the table and the data type of each attribute in the schema.How do I get this? Karteek

    H 1 Reply Last reply
    0
    • K karteek

      Hi, I have a dataset object and I am filling it with the rows of a table.Now I assigned it to a datagrid object.I don't know the schema of the table.Now I want the schema of the table and the data type of each attribute in the schema.How do I get this? Karteek

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      You can't get the schema from the DataGrid like you're probably hoping. You could construct an XmlDocument (or use an XmlTextWriter) to build a schema while enumerating through the tables and column definitions, but the easiest way is to create a typed DataSet by adding a new DataSet schema to your project and designing the desired schema in there. VS.NET can generate a typed DataSet class (with actual table and column names, as well as the proper column types and fewer look-ups). You can use this to bind more easily to a DataGrid. At the very least - if you don't want to use the actual typed DataSet - you'll have a schema that you can use for DataSet.ReadXmlSchema for a generic DataSet instance. To bind to a DataGrid, though, you really don't need to know the schema in advance. You can always set the DataGrid.DataSource property to the DataSet instance (filled) and optionally set the DataMember to myDataSet.Tables[0].TableName. By default, columns are generated automatically. If you know the schema up-front - you don't even have to import any schema - you can pre-set the DataGrid.DataMember property to the table name and add a DataGridTableStyle to DataGrid.TableStyles that uses the same table name. Optionally, you can add various DataGridColumnStylesd to the associated DataGridTableStyle.GridColumnStyles collection property and set DataGrid.AutoGenerateColumns to false. See the documentation for any one of the mentioned classes and / or properties for more information and examples.

      Microsoft MVP, Visual C# My Articles

      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