|
-
Jun 2nd, 2005, 10:25 PM
#1
Thread Starter
Fanatic Member
[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:
Public Sub CreateGrid()
'Declare new grid
Dim dgLetters As New DataGrid
dgLetters.BorderWidth = Unit.Pixel(2)
dgLetters.CellPadding = 10
dgLetters.GridLines = GridLines.Both
dgLetters.BorderColor = Color.Blue
dgLetters.ShowHeader = True
dgLetters.AutoGenerateColumns = False
dgLetters.HeaderStyle.BackColor = Color.Blue
dgLetters.HeaderStyle.ForeColor = Color.White
dgLetters.Font.Name = "Arial"
'Add bound Columns
'column for checkbox
Dim datagridcol_Checkbox As New BoundColumn
datagridcol_Checkbox.HeaderText = "Check To Print"
dgLetters.Columns.Add(datagridcol_Checkbox)
Dim datagridcol_letter As New BoundColumn
datagridcol_letter.HeaderText = "Letter Name"
datagridcol_letter.DataField = "letter_name"
dgLetters.Columns.Add(datagridcol_letter)
Dim datagridcol_desc As New BoundColumn
datagridcol_desc.HeaderText = "Description"
datagridcol_desc.DataField = "letter_description"
dgLetters.Columns.Add(datagridcol_desc)
'Bind Data
dgLetters.DataSource = GetDataSet()
dgLetters.DataBind()
'Add datagrid to page
Page.Controls(1).Controls.Add(dgLetters)
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.
-
Jun 2nd, 2005, 11:49 PM
#2
Thread Starter
Fanatic Member
Re: Adding a checkbox column to datagrid
Ok nevermind that I got it, now I need to grab the value of a specific cell of which ever line of the grid is selected...
I've tried everything but it keeps erroring out on me. I'm writing my code in my DataGrid_SelectedIndexChanged sub.
-
Jun 2nd, 2005, 11:55 PM
#3
Thread Starter
Fanatic Member
Re: Adding a checkbox column to datagrid

Got it on my own.
VB Code:
Dim eventID as Integer = DataGrid1.SelectedIndex.Cells(3).Text
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|