how to check/Uncheck a checkbox dynamically in a datagrid in asp.n

Discussion in 'ASP .Net' started by =?Utf-8?B?U2lsZWVzaA==?=, Oct 15, 2004.

  1. Hi

    I have datagrid with 8 items. Out of which 2 items are checkboxes. Data is
    binded dynamically to the datagrid

    Based on some values from the database I have to check or uncheck the
    checkbox in the datatgrid.

    Does any one know how to do this?

    Thx
    Sileesh
     
    =?Utf-8?B?U2lsZWVzaA==?=, Oct 15, 2004
    #1
    1. Advertising

  2. You can use an IIF statement in the ItemTemplate like this when you get the
    value from the database:

    Checked='<%# IIF(DataBinder.Eval(Container,
    "DataItem.Boolean"),"true","false") %>'

    Or, if the database already has a boolean, you ca do this:

    Checked='<%# DataBinder.Eval(Container, "DataItem.Boolean") %>'

    More code below.

    Does this help?

    Ken
    Microsoft MVP [ASP.NET]



    <asp:TemplateColumn HeaderText="Boolean Value">
    <ItemTemplate>
    <asp:CheckBox id=match runat="server" onCheckedChanged="updateStatus"
    Checked='<%# DataBinder.Eval(Container, "DataItem.Boolean") %>'
    AutoPostBack="True">
    </asp:CheckBox>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn HeaderText="Boolean Value">
    <ItemTemplate>
    <asp:CheckBox id="Checkbox1" runat="server"
    onCheckedChanged="updateStatus" Checked='<%# IIF(DataBinder.Eval(Container,
    "DataItem.Boolean"),"true","false") %>' AutoPostBack="True">
    </asp:CheckBox>
    </ItemTemplate>
    </asp:TemplateColumn>

    "Sileesh" <> wrote in message
    news:...
    > Hi
    >
    > I have datagrid with 8 items. Out of which 2 items are checkboxes. Data is
    > binded dynamically to the datagrid
    >
    > Based on some values from the database I have to check or uncheck the
    > checkbox in the datatgrid.
    >
    > Does any one know how to do this?
    >
    > Thx
    > Sileesh
     
    Ken Cox [Microsoft MVP], Oct 15, 2004
    #2
    1. Advertising

  3. Re: how to check/Uncheck a checkbox dynamically in a datagrid in a

    Ken

    Thanks for the exanple. Thanks for ur effort os explaining.
    but I am working on windows form. In that i don't runat server procedures.
    Can u tell how i can do with code behind in vb.net.

    Rekha

    "Ken Cox [Microsoft MVP]" wrote:

    > You can use an IIF statement in the ItemTemplate like this when you get the
    > value from the database:
    >
    > Checked='<%# IIF(DataBinder.Eval(Container,
    > "DataItem.Boolean"),"true","false") %>'
    >
    > Or, if the database already has a boolean, you ca do this:
    >
    > Checked='<%# DataBinder.Eval(Container, "DataItem.Boolean") %>'
    >
    > More code below.
    >
    > Does this help?
    >
    > Ken
    > Microsoft MVP [ASP.NET]
    >
    >
    >
    > <asp:TemplateColumn HeaderText="Boolean Value">
    > <ItemTemplate>
    > <asp:CheckBox id=match runat="server" onCheckedChanged="updateStatus"
    > Checked='<%# DataBinder.Eval(Container, "DataItem.Boolean") %>'
    > AutoPostBack="True">
    > </asp:CheckBox>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > <asp:TemplateColumn HeaderText="Boolean Value">
    > <ItemTemplate>
    > <asp:CheckBox id="Checkbox1" runat="server"
    > onCheckedChanged="updateStatus" Checked='<%# IIF(DataBinder.Eval(Container,
    > "DataItem.Boolean"),"true","false") %>' AutoPostBack="True">
    > </asp:CheckBox>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    >
    > "Sileesh" <> wrote in message
    > news:...
    > > Hi
    > >
    > > I have datagrid with 8 items. Out of which 2 items are checkboxes. Data is
    > > binded dynamically to the datagrid
    > >
    > > Based on some values from the database I have to check or uncheck the
    > > checkbox in the datatgrid.
    > >
    > > Does any one know how to do this?
    > >
    > > Thx
    > > Sileesh

    >
    >
     
    =?Utf-8?B?UmVraGE=?=, Dec 2, 2004
    #3
  4. Re: how to check/Uncheck a checkbox dynamically in a datagrid in a

    Wrong group for Windows Forms. This is ASP.NET.


    "Rekha" <> wrote in message
    news:...
    > Ken
    >
    > Thanks for the exanple. Thanks for ur effort os explaining.
    > but I am working on windows form. In that i don't runat server procedures.
    > Can u tell how i can do with code behind in vb.net.
    >
    > Rekha
     
    Ken Cox [Microsoft MVP], Dec 2, 2004
    #4
  5. Re: how to check/Uncheck a checkbox dynamically in a datagrid in a

    thanks ..

    "Ken Cox [Microsoft MVP]" wrote:

    > Wrong group for Windows Forms. This is ASP.NET.
    >
    >
    > "Rekha" <> wrote in message
    > news:...
    > > Ken
    > >
    > > Thanks for the exanple. Thanks for ur effort os explaining.
    > > but I am working on windows form. In that i don't runat server procedures.
    > > Can u tell how i can do with code behind in vb.net.
    > >
    > > Rekha

    >
    >
     
    =?Utf-8?B?UmVraGE=?=, Dec 2, 2004
    #5
    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?UmVraGE=?=

    how to check/uncheck the checkbox in datagrid

    =?Utf-8?B?UmVraGE=?=, Dec 2, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    992
    =?Utf-8?B?UmVraGE=?=
    Dec 2, 2004
  2. Neal
    Replies:
    2
    Views:
    4,288
    subashini
    Mar 5, 2012
  3. pavankumarkavety
    Replies:
    0
    Views:
    1,067
    pavankumarkavety
    May 22, 2008
  4. Lew
    Replies:
    1
    Views:
    2,213
    Danjojo
    Sep 7, 2010
  5. marian

    dyanmic checkbox/itemplate/checkedchanged uncheck issue

    marian, Aug 8, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    178
    marian
    Aug 8, 2005
Loading...

Share This Page