Checkbox value in datagrid does not reflect appearance

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default Checkbox value in datagrid does not reflect appearance

    I have a datagrid with boolean columns and as a test I display the value of
    the checkbox in a label (not bound) as the user clicks in the grid cell.
    Depending on the value of the checkbox as set by the user, my code should go
    different routes.

    My problem is that the value of that particular cell stays the same
    regardless of its visible appearance. Only when the user re-enters the cell
    after selecting a different row, does the value reflect the actual visibly
    set value. The value then changes again but referencing it as set out below
    shows the value when the user entered the cell.

    In the datagrid's click event I used:

    Label1.Text +=
    DataSet71.Tables("MyTable").DefaultView.Item(DataG rid1.CurrentRowIndex).Item(1).ToString

    and also

    Label1.Text += DataGrid1.Item(DataGrid1.CurrentRowIndex, 1).ToString()

    For each click the above event is fired and add to the label's text, but the
    grid cell's value do not change, eventhough the checkbox visibly changes its
    value. The true value is only displayed (in the label) on re-entering the
    cell.

    I need my code to run on the click event of the datagrid and the value of
    the checkbox should determine what should happen.

    How can I get the actual value (as displayed by the checkbox)?
    PaulNaude Guest

  2. Similar Questions and Discussions

    1. DataGrid Buttons Appearance
      I have been trying to figure out how to change the color of the Button on my datagrid. And when I try to change the back color it changes the color...
    2. Howto bind CheckBox to the datagrid/ Then update the database field when the checkbox is clicked.
      I am trying to update the database field when the checkbox is clicked. I am trying to modified the following solution but.. got stuck on the...
    3. Datagrid does not reflect update
      Hi all, The problem I have is when I assign an update to a datagrid cell, the change only shows after I mouse over it. If I turn off...
    4. Changing the appearance of datagrid
      I need to change the datagrid header color to be solid blue instead of gradient blue. I tried of using style sheet and called that style in...
    5. Added CheckBox to a DataGrid Doesn't work with DataGrid.Enabled=False
      I have created a Template Column and Added to a Datagrid, which contains a checkBox. The column is not Binded to any column of the Dataset, but is...
  3. #2

    Default Re: Checkbox value in datagrid does not reflect appearance

    Following code shows how to get value from a checkbox:

    Dim ck As CheckBox = CType(e.Item.FindControl("checkbox_ID"), CheckBox )
    Dim ckValue = ck.Checked.ToString

    HTH

    "PaulNaude" <PaulNaude@discussions.microsoft.com> wrote in message
    news:49B03209-5145-4B86-842F-5B44A84AD3F3@microsoft.com...
    >I have a datagrid with boolean columns and as a test I display the value of
    > the checkbox in a label (not bound) as the user clicks in the grid cell.
    > Depending on the value of the checkbox as set by the user, my code should
    > go
    > different routes.
    >
    > My problem is that the value of that particular cell stays the same
    > regardless of its visible appearance. Only when the user re-enters the
    > cell
    > after selecting a different row, does the value reflect the actual visibly
    > set value. The value then changes again but referencing it as set out
    > below
    > shows the value when the user entered the cell.
    >
    > In the datagrid's click event I used:
    >
    > Label1.Text +=
    > DataSet71.Tables("MyTable").DefaultView.Item(DataG rid1.CurrentRowIndex).Item(1).ToString
    >
    > and also
    >
    > Label1.Text += DataGrid1.Item(DataGrid1.CurrentRowIndex, 1).ToString()
    >
    > For each click the above event is fired and add to the label's text, but
    > the
    > grid cell's value do not change, eventhough the checkbox visibly changes
    > its
    > value. The true value is only displayed (in the label) on re-entering the
    > cell.
    >
    > I need my code to run on the click event of the datagrid and the value of
    > the checkbox should determine what should happen.
    >
    > How can I get the actual value (as displayed by the checkbox)?

    Elton Wang Guest

  4. #3

    Default Re: Checkbox value in datagrid does not reflect appearance

    Thanks but I am not sure how to reference any particular records' checkbox in
    my datagrid, other than by specifying the cell.

    I tried : Dim ck As CheckBox =
    CType(DataGrid1.Item(DataGrid1.CurrentRowIndex, 1), CheckBox) but obviously
    is not right.

    Where do you put your code? If I paste it into the datagrid click event ,
    'item' is not a member of 'e'.

    thanks

    "Elton Wang" wrote:
    > Following code shows how to get value from a checkbox:
    >
    > Dim ck As CheckBox = CType(e.Item.FindControl("checkbox_ID"), CheckBox )
    > Dim ckValue = ck.Checked.ToString
    >
    > HTH
    >
    > "PaulNaude" <PaulNaude@discussions.microsoft.com> wrote in message
    > news:49B03209-5145-4B86-842F-5B44A84AD3F3@microsoft.com...
    > >I have a datagrid with boolean columns and as a test I display the value of
    > > the checkbox in a label (not bound) as the user clicks in the grid cell.
    > > Depending on the value of the checkbox as set by the user, my code should
    > > go
    > > different routes.
    > >
    > > My problem is that the value of that particular cell stays the same
    > > regardless of its visible appearance. Only when the user re-enters the
    > > cell
    > > after selecting a different row, does the value reflect the actual visibly
    > > set value. The value then changes again but referencing it as set out
    > > below
    > > shows the value when the user entered the cell.
    > >
    > > In the datagrid's click event I used:
    > >
    > > Label1.Text +=
    > > DataSet71.Tables("MyTable").DefaultView.Item(DataG rid1.CurrentRowIndex).Item(1).ToString
    > >
    > > and also
    > >
    > > Label1.Text += DataGrid1.Item(DataGrid1.CurrentRowIndex, 1).ToString()
    > >
    > > For each click the above event is fired and add to the label's text, but
    > > the
    > > grid cell's value do not change, eventhough the checkbox visibly changes
    > > its
    > > value. The true value is only displayed (in the label) on re-entering the
    > > cell.
    > >
    > > I need my code to run on the click event of the datagrid and the value of
    > > the checkbox should determine what should happen.
    > >
    > > How can I get the actual value (as displayed by the checkbox)?
    >
    >
    >
    PaulNaude Guest

  5. #4

    Default Re: Checkbox value in datagrid does not reflect appearance

    Please show your html view code of datagrid.

    BTW, where do you process checkbox, in datagrid_ItemCommand, or some other
    event?


    "PaulNaude" <PaulNaude@discussions.microsoft.com> wrote in message
    news:15DC995A-A35D-4513-A7AB-CE746251DDB1@microsoft.com...
    > Thanks but I am not sure how to reference any particular records' checkbox
    > in
    > my datagrid, other than by specifying the cell.
    >
    > I tried : Dim ck As CheckBox =
    > CType(DataGrid1.Item(DataGrid1.CurrentRowIndex, 1), CheckBox) but
    > obviously
    > is not right.
    >
    > Where do you put your code? If I paste it into the datagrid click event ,
    > 'item' is not a member of 'e'.
    >
    > thanks
    >
    > "Elton Wang" wrote:
    >
    >> Following code shows how to get value from a checkbox:
    >>
    >> Dim ck As CheckBox = CType(e.Item.FindControl("checkbox_ID"), CheckBox )
    >> Dim ckValue = ck.Checked.ToString
    >>
    >> HTH
    >>
    >> "PaulNaude" <PaulNaude@discussions.microsoft.com> wrote in message
    >> news:49B03209-5145-4B86-842F-5B44A84AD3F3@microsoft.com...
    >> >I have a datagrid with boolean columns and as a test I display the value
    >> >of
    >> > the checkbox in a label (not bound) as the user clicks in the grid
    >> > cell.
    >> > Depending on the value of the checkbox as set by the user, my code
    >> > should
    >> > go
    >> > different routes.
    >> >
    >> > My problem is that the value of that particular cell stays the same
    >> > regardless of its visible appearance. Only when the user re-enters the
    >> > cell
    >> > after selecting a different row, does the value reflect the actual
    >> > visibly
    >> > set value. The value then changes again but referencing it as set out
    >> > below
    >> > shows the value when the user entered the cell.
    >> >
    >> > In the datagrid's click event I used:
    >> >
    >> > Label1.Text +=
    >> > DataSet71.Tables("MyTable").DefaultView.Item(DataG rid1.CurrentRowIndex).Item(1).ToString
    >> >
    >> > and also
    >> >
    >> > Label1.Text += DataGrid1.Item(DataGrid1.CurrentRowIndex, 1).ToString()
    >> >
    >> > For each click the above event is fired and add to the label's text,
    >> > but
    >> > the
    >> > grid cell's value do not change, eventhough the checkbox visibly
    >> > changes
    >> > its
    >> > value. The true value is only displayed (in the label) on re-entering
    >> > the
    >> > cell.
    >> >
    >> > I need my code to run on the click event of the datagrid and the value
    >> > of
    >> > the checkbox should determine what should happen.
    >> >
    >> > How can I get the actual value (as displayed by the checkbox)?
    >>
    >>
    >>

    Elton Wang Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139