Results 1 to 3 of 3

Thread: Manually specifying columns in a datagrid

  1. #1

    Thread Starter
    Hyperactive Member MarkusJ_NZ's Avatar
    Join Date
    Jun 2001
    Posts
    375

    Manually specifying columns in a datagrid

    Hi, I have a dataview that 'views' some information returned by a dataset.

    I can autobind a datagrid to the view so that all information is automatically populated within the datagrid.

    What I wuld like to do is specify the column headers as well as their associated attribute in the dataset via code.

    e.g datagrid.columns.add(.....

    thanks for any help/ advice

    MarkusJ

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367
    Try something like this:

    Code:
                
        Dim dt As New DataTable
        Dim ds as new DataSet
        Dim dc as DataColumn()
    dc = New DataColumn()
                dc.ColumnName = "Index"
                dc.DataType = System.Type.GetType("System.Int16")
                dc.ReadOnly = True
                dt.Columns.Add(dc)
                 ds.Tables.Add(dt)
            DataGrid1.DataSource = ds
            DataGrid1.DataBind()
    Hope this helps ya,

  3. #3

    Thread Starter
    Hyperactive Member MarkusJ_NZ's Avatar
    Join Date
    Jun 2001
    Posts
    375
    Cool thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width