Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > editing question

Reply
Thread Tools

editing question

 
 
Dean
Guest
Posts: n/a
 
      09-18-2003
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


 
Reply With Quote
 
 
 
 
Steve Roszko
Guest
Posts: n/a
 
      09-18-2003
> 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




 
Reply With Quote
 
 
 
 
Dean
Guest
Posts: n/a
 
      09-19-2003
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


"Steve Roszko" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> > 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
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Are you looking for high quality photo editing and video editing? gwanglu@gmail.com C Programming 0 07-19-2006 12:32 PM
Newbie question re editing ACLs S W Cisco 4 11-15-2005 04:45 PM
XML Editing,updating,deleting Question! =?Utf-8?B?UGF0cmljay5PLklnZQ==?= ASP .Net 0 11-24-2004 12:19 AM
images editing question RonW HTML 4 01-02-2004 09:56 AM
Apache Batik - Question on editing SVG file and transform the graphics to other formats (e.g. JPG, PNG...) Brian K Java 0 10-12-2003 03:44 PM



Advertisments