Results 1 to 3 of 3

Thread: [RESOLVED] Adding a checkbox column to datagrid

Threaded View

  1. #1

    Thread Starter
    Fanatic Member drpcken's Avatar
    Join Date
    Apr 2004
    Location
    devenv
    Posts
    591

    Resolved [RESOLVED] Adding a checkbox column to datagrid

    I have a datagrid I've coded and I need to add a checkbox to each row that is pulled from the sql table. The checkbox doesn't have to have a value assigned, I just need to use it to determine if the row is checked or not for a loop i have to run.

    here's my datagrid code so far, notice I've already setup the column header for the checkbox i just haven't figured out how to draw a checkbox for each row.

    VB Code:
    1. Public Sub CreateGrid()
    2.  
    3.         'Declare new grid
    4.         Dim dgLetters As New DataGrid
    5.         dgLetters.BorderWidth = Unit.Pixel(2)
    6.         dgLetters.CellPadding = 10
    7.         dgLetters.GridLines = GridLines.Both
    8.         dgLetters.BorderColor = Color.Blue
    9.         dgLetters.ShowHeader = True
    10.         dgLetters.AutoGenerateColumns = False
    11.         dgLetters.HeaderStyle.BackColor = Color.Blue
    12.         dgLetters.HeaderStyle.ForeColor = Color.White
    13.         dgLetters.Font.Name = "Arial"
    14.        
    15.         'Add bound Columns
    16.         'column for checkbox
    17.         Dim datagridcol_Checkbox As New BoundColumn
    18.         datagridcol_Checkbox.HeaderText = "Check To Print"
    19.         dgLetters.Columns.Add(datagridcol_Checkbox)
    20.  
    21.         Dim datagridcol_letter As New BoundColumn
    22.         datagridcol_letter.HeaderText = "Letter Name"
    23.         datagridcol_letter.DataField = "letter_name"
    24.         dgLetters.Columns.Add(datagridcol_letter)
    25.  
    26.         Dim datagridcol_desc As New BoundColumn
    27.         datagridcol_desc.HeaderText = "Description"
    28.         datagridcol_desc.DataField = "letter_description"
    29.         dgLetters.Columns.Add(datagridcol_desc)
    30.  
    31.         'Bind Data
    32.         dgLetters.DataSource = GetDataSet()
    33.         dgLetters.DataBind()
    34.  
    35.         'Add datagrid to page
    36.         Page.Controls(1).Controls.Add(dgLetters)
    37.     End Sub

    Whats going to happen is if an item is checked, it will loop through the grid when a button i place is check and add values to parameters in a stored procedure.

    Thanks!
    Last edited by drpcken; Jun 2nd, 2005 at 11:56 PM.

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