how to bind data to checkbox in datagrid

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

  1. #1

    Default how to bind data to checkbox in datagrid

    hi
    i have a datagrid and one colume is a bool
    if i use a normal asp:BoundColumn is shows as true or false
    and i want it to show as a checkbox
    but if i use a asp:TemplateColumn as this
    <asp:TemplateColumn>
    <HeaderTemplate>
    <b>Aktiv</b>
    </HeaderTemplate>
    <ItemTemplate>
    <asp:CheckBox Runat="server" ID="checkbox" ></asp:CheckBox>
    </ItemTemplate>
    </asp:TemplateColumn>

    i only get a checkbox how do i bind the data to the checkbox
    and i also want it to only bee able to check the box when it is in edit mode



    LiFo Guest

  2. Similar Questions and Discussions

    1. 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...
    2. How to bind checkbox to one of the values of a datagrid
      Hello All, I hope someone can enlighten me, all of the examples and posts Ihave read and sifted through doesn't pertain to what i wouldlike to do...
    3. Can we bind data to textbox in a headertemplate of a datagrid
      Can we bind data to textbox in a headertemplate in a template column of a datagrid? If so please give some code snippets. Thank you
    4. Including a Data Bound CheckBox in an Editable DataGrid...
      I found some good information On "Including a Data Bound CheckBox in an Editable DataGrid... " at this site...
    5. bind data to a textbox in a template column in WebForm DataGrid
      Hi, I am trying to put a textbox in a template column both for displaying and editing. When I add the following line to the HTML code...
  3. #2

    Default Re: how to bind data to checkbox in datagrid

    LiFo wrote:
    > hi
    > i have a datagrid and one colume is a bool
    > if i use a normal asp:BoundColumn is shows as true or false
    > and i want it to show as a checkbox
    > but if i use a asp:TemplateColumn as this
    > <asp:TemplateColumn>
    > <HeaderTemplate>
    > <b>Aktiv</b>
    > </HeaderTemplate>
    > <ItemTemplate>
    > <asp:CheckBox Runat="server" ID="checkbox" ></asp:CheckBox>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    >
    > i only get a checkbox how do i bind the data to the checkbox
    > and i also want it to only bee able to check the box when it is in
    > edit mode
    For Visual Basic:
    <asp:CheckBox Runat="server" ID="checkbox1"
    Checked='<%# DataBinder.Eval(Container.DataItem, "myField") %>' >
    </asp:CheckBox>

    I suggest using "Checkbox1" and not "Checkbox" for the ID, as Checkbox
    can cause confusion between the type and the instance.

    --

    Jos Branders


    Jos Guest

  4. #3

    Default Re: how to bind data to checkbox in datagrid

    i am using c# and cant get it to work ???



    "Jos" <josnospambranders@fastmail.fm> wrote in message
    news:uJbJ4KPrDHA.3256@tk2msftngp13.phx.gbl...
    > LiFo wrote:
    > > hi
    > > i have a datagrid and one colume is a bool
    > > if i use a normal asp:BoundColumn is shows as true or false
    > > and i want it to show as a checkbox
    > > but if i use a asp:TemplateColumn as this
    > > <asp:TemplateColumn>
    > > <HeaderTemplate>
    > > <b>Aktiv</b>
    > > </HeaderTemplate>
    > > <ItemTemplate>
    > > <asp:CheckBox Runat="server" ID="checkbox" ></asp:CheckBox>
    > > </ItemTemplate>
    > > </asp:TemplateColumn>
    > >
    > > i only get a checkbox how do i bind the data to the checkbox
    > > and i also want it to only bee able to check the box when it is in
    > > edit mode
    >
    > For Visual Basic:
    > <asp:CheckBox Runat="server" ID="checkbox1"
    > Checked='<%# DataBinder.Eval(Container.DataItem, "myField") %>' >
    > </asp:CheckBox>
    >
    > I suggest using "Checkbox1" and not "Checkbox" for the ID, as Checkbox
    > can cause confusion between the type and the instance.
    >
    > --
    >
    > Jos Branders
    >
    >

    LiFo Guest

  5. #4

    Default Re: how to bind data to checkbox in datagrid

    LiFo wrote:
    > i am using c# and cant get it to work ???
    I checked and it's exactly the same in c#.
    Did you replace "myField" with the actual name of your field,
    for instance "Activ"?

    What is your error message?

    --

    Jos Branders


    Jos Guest

  6. #5

    Default Re: how to bind data to checkbox in datagrid

    thanks i have got it to work now
    it was just a small typho

    "Jos" <josnospambranders@fastmail.fm> wrote in message
    news:%23dWXBwQrDHA.1408@TK2MSFTNGP11.phx.gbl...
    > LiFo wrote:
    > > i am using c# and cant get it to work ???
    >
    > I checked and it's exactly the same in c#.
    > Did you replace "myField" with the actual name of your field,
    > for instance "Activ"?
    >
    > What is your error message?
    >
    > --
    >
    > Jos Branders
    >
    >

    LiFo 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