editing question

D

Dean

When editing text columns in a datagrid the existing value of the column
appears in the textboxes when the boxes are first displayed. Even if the
column is a bit column it will either say 'true' or 'false'.

But, when I convert the bit column to a template column, a checkbox, the box
is displayed unchecked regardless of the existing value of the column. How
can I get the existing value to work in this checkbox case?
Thanks,
Dean
 
S

Steve Roszko

But, when I convert the bit column to a template column, a checkbox, the
box
is displayed unchecked regardless of the existing value of the column. How
can I get the existing value to work in this checkbox case?


You can use the ItemDataBound event of the DataGrid. Something like:


Private Sub dgProjTasks_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
dgProjTasks.ItemDataBound

'Enable/Disable check boxes if task is complete or not
'cols 0 and 1 are hidden values in the datagrid
If e.Item.ItemType.ToString() = "Item" Or e.Item.ItemType.ToString() =
"AlternatingItem" Then

Dim projDetailID As Integer = e.Item.Cells(0).Text
Dim myBit As Integer = e.Item.Cells(1).Text
Dim mychk As CheckBox = e.Item.FindControl("chkWorkDone")

If myBit = 1 Then
mychk.Checked = True
Else
mychk.Checked = False
End If

End If

End Sub



-Steve
 
D

Dean

Steve,
I think you might have misunderstood my question. The datacolumn is defined
as type binary and it displays just fine when the grid is displayed. It
either says 'True' or False'. The problem occurs when the edit button is
pushed for a row. the display then changes showing a textbox for the first
column with the existing value in it and a checkbox for the second column
that is always unchecked regardless of the value of that column. If the
column is true for that row then I want the checkbox to show as checked in
the edit window.
Dean
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top