Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Checkbox in a Datagrid with an CheckedChanged event?

Reply
Thread Tools

Checkbox in a Datagrid with an CheckedChanged event?

 
 
REB
Guest
Posts: n/a
 
      03-01-2004
I am trying to create a CheckChanged event for a check box in a datagrid so
that when a user checks or unchecks the box a update is done for the record.

Can anyone point my in the right direction?

Thanks,
REB


 
Reply With Quote
 
 
 
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      03-02-2004
Your post went unanswered. Have you resolved this issue?

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"REB" <(E-Mail Removed)> wrote in message
news:ujkHEE9$(E-Mail Removed)...
> I am trying to create a CheckChanged event for a check box in a datagrid

so
> that when a user checks or unchecks the box a update is done for the

record.
>
> Can anyone point my in the right direction?
>
> Thanks,
> REB
>
>



 
Reply With Quote
 
 
 
 
REB
Guest
Posts: n/a
 
      03-02-2004
No I have not yet figured it out. There must be a way to manually create a
checkedchanged event for the checkboxes in the grid, but I do not know how.

Still searching,
REB


"REB" <(E-Mail Removed)> wrote in message
news:ujkHEE9$(E-Mail Removed)...
> I am trying to create a CheckChanged event for a check box in a datagrid

so
> that when a user checks or unchecks the box a update is done for the

record.
>
> Can anyone point my in the right direction?
>
> Thanks,
> REB
>
>



 
Reply With Quote
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      03-02-2004
It really depends on how you added the control to the grid. If it is
embedded in the column (it likely is) it will fire off the itemcommand
automatically. So you can place your code in there. Use the sender argument
or the commandname property to determine if it came from the checkbox or
somewhere else.

Otherwise, if you created the checkbox dynamically, you will need to
manually wire it up to an event like so
this.CheckBox1.Checked += new System.EventHandler(some_function_goes_here);

You would then place the appropriate code in some_function_goes_here
function


--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"REB" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> No I have not yet figured it out. There must be a way to manually create

a
> checkedchanged event for the checkboxes in the grid, but I do not know

how.
>
> Still searching,
> REB
>
>
> "REB" <(E-Mail Removed)> wrote in message
> news:ujkHEE9$(E-Mail Removed)...
> > I am trying to create a CheckChanged event for a check box in a datagrid

> so
> > that when a user checks or unchecks the box a update is done for the

> record.
> >
> > Can anyone point my in the right direction?
> >
> > Thanks,
> > REB
> >
> >

>
>



 
Reply With Quote
 
REB
Guest
Posts: n/a
 
      03-03-2004
The control is embedded, but it does not seem to automatically fire off the
itemcommand for the datagrid. I put a simple Response.Write in the
itemcommand function for the datagrid and it did not work.

My datagrid is simple and only has 4 columns (one of which is the key field
and is invisible) I included the html for the datagrid at the end of this
message, but without formatiing is really hard to read here in the newsgroup
if that helps.

The name of my check box in the templated column is checkbox1 how do I use
the sender argument to tell if it has been clicked?

Thanks,
REB

<asp:textbox id="txtViolationType" runat="server"
Width="236px"></asp:textbox><asp:button id="btnSaveViolation" runat="server"
Text="Save Violation"
CausesValidation="False"></asp:button></FONT></STRONG><STRONG><FONT
size="2"><asp:datagrid id=dgTrafficViolations runat="server"
BorderStyle="None" BackColor="White" AutoGenerateColumns="False"
DataMember="Table" DataKeyField="DriverViolationID" DataSource="<%#
dsViolations1 %>" BorderColor="#CC9966" BorderWidth="1px" CellPadding="4">
<SelectedItemStyle Font-Bold="True" ForeColor="#663399"
BackColor="#FFCC66"></SelectedItemStyle>
<ItemStyle ForeColor="#330099" BackColor="White"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#FFFFCC"
BackColor="#990000"></HeaderStyle>
<FooterStyle ForeColor="#330099" BackColor="#FFFFCC"></FooterStyle>
<Columns>
<asp:BoundColumn Visible="False" DataField="DriverViolationID"
SortExpression="DriverViolationID"
HeaderText="DriverViolationID">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundColumn>
<asp:TemplateColumn HeaderText="Violations Notice">
<ItemTemplate>
<asp:CheckBox id=CheckBox1 runat="server" AutoPostBack="True"
Checked='<%# DataBinder.Eval(Container, "DataItem.DriverTraffic Violations
Notice") %>'>
</asp:CheckBox>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id=TextBox1 runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.DriverTraffic Violations Notice") %>'>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="DriverTrafficViolationsNoticeDate"
SortExpression="DriverTrafficViolationsNoticeDate"
HeaderText="Notice Date"
DataFormatString="{0:d}"></asp:BoundColumn>
<asp:BoundColumn DataField="DriverViolationType"
SortExpression="DriverViolationType"
HeaderText="Violation"></asp:BoundColumn>
</Columns>
<PagerStyle HorizontalAlign="Center" ForeColor="#330099"
BackColor="#FFFFCC"></PagerStyle>
</asp:datagrid>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic CheckBox CheckedChanged event not firing dilip.movva@gmail.com ASP .Net 2 10-17-2005 04:23 PM
dyanmic checkbox/itemplate/checkedchanged uncheck issue marian ASP .Net Datagrid Control 0 08-08-2005 06:13 PM
CheckedChanged Event doesn't work? Jump Off! ASP .Net 3 07-07-2004 05:29 PM
Re: Checkbox.CheckedChanged still has a mind of its own Chris Jackson ASP .Net 0 12-09-2003 04:57 PM
Checkbox.CheckedChanged has a mind of its own Greg Hurlman ASP .Net 5 12-04-2003 07:14 PM



Advertisments