Responding to checkbox in datagrid

Discussion in 'ASP .Net Datagrid Control' started by Paul, May 25, 2004.

  1. Paul

    Paul Guest

    I have a datagrid in which I am displaying a column as a checkbox. A
    snippet of the aspx code where I use a template column to do this is shown
    below.

    I am at a loss as to how to respond to the checkbox being clicked. Any help
    would be appreciated.

    TIA

    Paul

    <asp:datagrid id="gridLocBased" style="Z-INDEX: 101; LEFT: 46px;
    POSITION: absolute; TOP: 71px" runat="server" BorderWidth="3px"
    BorderColor="DarkGray" BorderStyle="Double" AutoGenerateColumns="False"
    HorizontalAlign="Center" Width="469px">
    <AlternatingItemStyle Font-Size="X-Small"
    BackColor="Cornsilk"></AlternatingItemStyle>
    <ItemStyle Font-Size="X-Small" BorderWidth="3px" BorderStyle="Double"
    BackColor="WhiteSmoke"></ItemStyle>
    <HeaderStyle Font-Size="X-Small" Font-Bold="True"
    HorizontalAlign="Center" ForeColor="Cornsilk"
    BackColor="RoyalBlue"></HeaderStyle>
    <Columns>
    <asp:TemplateColumn HeaderText="Enabled">
    <HeaderStyle Width="60px"></HeaderStyle>
    <ItemStyle HorizontalAlign="Center"></ItemStyle>
    <ItemTemplate>
    <asp:CheckBox runat="server" ID="cbxEnabled" Checked='<%#
    Convert.ToBoolean( DataBinder.Eval( Container, "DataItem.Enabled" ) ) %>'
    AutoPostBack="true">
    </asp:CheckBox>
    </ItemTemplate>
    </asp:TemplateColumn>
    Paul, May 25, 2004
    #1
    1. Advertising

  2. Paul

    Rick Spiewak Guest

    You can add a handler to the checkbox during the pageload event. If you are
    in edit mode, you can find the row from the edititemindex, then find the
    checkbox by its ID and add the handler.

    "Paul" <> wrote in message
    news:u$...
    > I have a datagrid in which I am displaying a column as a checkbox. A
    > snippet of the aspx code where I use a template column to do this is shown
    > below.
    >
    > I am at a loss as to how to respond to the checkbox being clicked. Any

    help
    > would be appreciated.
    >
    > TIA
    >
    > Paul
    >
    > <asp:datagrid id="gridLocBased" style="Z-INDEX: 101; LEFT: 46px;
    > POSITION: absolute; TOP: 71px" runat="server" BorderWidth="3px"
    > BorderColor="DarkGray" BorderStyle="Double" AutoGenerateColumns="False"
    > HorizontalAlign="Center" Width="469px">
    > <AlternatingItemStyle Font-Size="X-Small"
    > BackColor="Cornsilk"></AlternatingItemStyle>
    > <ItemStyle Font-Size="X-Small" BorderWidth="3px" BorderStyle="Double"
    > BackColor="WhiteSmoke"></ItemStyle>
    > <HeaderStyle Font-Size="X-Small" Font-Bold="True"
    > HorizontalAlign="Center" ForeColor="Cornsilk"
    > BackColor="RoyalBlue"></HeaderStyle>
    > <Columns>
    > <asp:TemplateColumn HeaderText="Enabled">
    > <HeaderStyle Width="60px"></HeaderStyle>
    > <ItemStyle HorizontalAlign="Center"></ItemStyle>
    > <ItemTemplate>
    > <asp:CheckBox runat="server" ID="cbxEnabled" Checked='<%#
    > Convert.ToBoolean( DataBinder.Eval( Container, "DataItem.Enabled" ) ) %>'
    > AutoPostBack="true">
    > </asp:CheckBox>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    >
    >
    Rick Spiewak, May 26, 2004
    #2
    1. Advertising

  3. Paul

    Paul Guest

    I found another solution that seems to work well at:

    http://www.codeproject.com/aspnet/datagridccevents.asp?msg=822011


    "Rick Spiewak" <> wrote in message
    news:...
    > You can add a handler to the checkbox during the pageload event. If you

    are
    > in edit mode, you can find the row from the edititemindex, then find the
    > checkbox by its ID and add the handler.
    >
    > "Paul" <> wrote in message
    > news:u$...
    > > I have a datagrid in which I am displaying a column as a checkbox. A
    > > snippet of the aspx code where I use a template column to do this is

    shown
    > > below.
    > >
    > > I am at a loss as to how to respond to the checkbox being clicked. Any

    > help
    > > would be appreciated.
    > >
    > > TIA
    > >
    > > Paul
    > >
    > > <asp:datagrid id="gridLocBased" style="Z-INDEX: 101; LEFT: 46px;
    > > POSITION: absolute; TOP: 71px" runat="server" BorderWidth="3px"
    > > BorderColor="DarkGray" BorderStyle="Double" AutoGenerateColumns="False"
    > > HorizontalAlign="Center" Width="469px">
    > > <AlternatingItemStyle Font-Size="X-Small"
    > > BackColor="Cornsilk"></AlternatingItemStyle>
    > > <ItemStyle Font-Size="X-Small" BorderWidth="3px"

    BorderStyle="Double"
    > > BackColor="WhiteSmoke"></ItemStyle>
    > > <HeaderStyle Font-Size="X-Small" Font-Bold="True"
    > > HorizontalAlign="Center" ForeColor="Cornsilk"
    > > BackColor="RoyalBlue"></HeaderStyle>
    > > <Columns>
    > > <asp:TemplateColumn HeaderText="Enabled">
    > > <HeaderStyle Width="60px"></HeaderStyle>
    > > <ItemStyle HorizontalAlign="Center"></ItemStyle>
    > > <ItemTemplate>
    > > <asp:CheckBox runat="server" ID="cbxEnabled" Checked='<%#
    > > Convert.ToBoolean( DataBinder.Eval( Container, "DataItem.Enabled" ) )

    %>'
    > > AutoPostBack="true">
    > > </asp:CheckBox>
    > > </ItemTemplate>
    > > </asp:TemplateColumn>
    > >
    > >

    >
    >
    Paul, May 26, 2004
    #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?QnJhZCBTaW1vbg==?=

    Datagrid not responding

    =?Utf-8?B?QnJhZCBTaW1vbg==?=, Jan 16, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    366
    BBeasley
    Jan 18, 2004
  2. Dave
    Replies:
    0
    Views:
    321
  3. Replies:
    2
    Views:
    560
  4. =?Utf-8?B?RG90TmV0RGV2?=

    DataGrid and embeded Checkbox..How to find if checkbox clicked

    =?Utf-8?B?RG90TmV0RGV2?=, Oct 6, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    802
    David Wier
    Oct 6, 2006
  5. Joey Pang
    Replies:
    4
    Views:
    505
    Joey Pang
    Jun 13, 2005
Loading...

Share This Page