Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Datagrid Control (http://www.velocityreviews.com/forums/f60-asp-net-datagrid-control.html)
-   -   Responding to checkbox in datagrid (http://www.velocityreviews.com/forums/t760650-responding-to-checkbox-in-datagrid.html)

Paul 05-25-2004 06:38 PM

Responding to checkbox in datagrid
 
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 05-26-2004 11:53 AM

Re: Responding to checkbox in datagrid
 
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" <no.paul.gibson.spam@i-stat.com> wrote in message
news:u$MV1doQEHA.3140@TK2MSFTNGP11.phx.gbl...
> 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 05-26-2004 03:35 PM

Re: Responding to checkbox in datagrid
 
I found another solution that seems to work well at:

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


"Rick Spiewak" <rickspiewak@mindspring.com> wrote in message
news:eHpTQgxQEHA.252@TK2MSFTNGP10.phx.gbl...
> 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" <no.paul.gibson.spam@i-stat.com> wrote in message
> news:u$MV1doQEHA.3140@TK2MSFTNGP11.phx.gbl...
> > 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>
> >
> >

>
>





All times are GMT. The time now is 08:02 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.