editing question

Discussion in 'ASP .Net Datagrid Control' started by Dean, Sep 18, 2003.

  1. Dean

    Dean Guest

    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
    Dean, Sep 18, 2003
    #1
    1. Advertising

  2. Dean

    Steve Roszko Guest

    > 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
    Steve Roszko, Sep 18, 2003
    #2
    1. Advertising

  3. Dean

    Dean Guest

    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" <> wrote in message
    news:...
    > > 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
    >
    >
    >
    >
    Dean, Sep 19, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UGF0cmljay5PLklnZQ==?=

    XML Editing,updating,deleting Question!

    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=, Nov 24, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    366
    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=
    Nov 24, 2004
  2. Brian K
    Replies:
    0
    Views:
    827
    Brian K
    Oct 12, 2003
  3. RonW

    images editing question

    RonW, Jan 1, 2004, in forum: HTML
    Replies:
    4
    Views:
    421
  4. richp
    Replies:
    10
    Views:
    629
    Safalra
    Feb 2, 2004
  5. Replies:
    0
    Views:
    573
Loading...

Share This Page