Results 1 to 2 of 2

Thread: DataGrid Columns

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Pilipinas
    Posts
    441

    DataGrid Columns

    Hi just asking on how to add columns in DataGrid manually? using only code..

  2. #2
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552
    i add it in a datatable
    VB Code:
    1. Dim cn As New SqlConnection()
    2.       cn.ConnectionString = "user id=sa;password=password;initial catalog=northwind"
    3.       cn.Open()
    4.  
    5.       Dim dt As New DataTable()
    6.       Dim cmdtext As String = "select * from categories"
    7.  
    8.       Dim da As New SqlDataAdapter(cmdtext, cn)
    9.       da.Fill(dt)
    10.       dt.Columns.Add("Brown Monkey")   'hehe
    11.  
    12.       DataGrid1.DataSource = dt
    13.  
    14.       cn.Close()

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