Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > RE: Capture the Checkbox Event from DataGrid

Reply
Thread Tools

RE: Capture the Checkbox Event from DataGrid

 
 
Viny
Guest
Posts: n/a
 
      10-23-2003

Hello,
I am looking for the same things. Get the value of the checkbox and update it to the database. Any help will be appreciated. I dont have a update button in the datagrid. My update button is outside the datagrid.
Thanks
Viny

>Hi Everyone,
>My Datagrid has a TemplateColumn contains checkbox control and I set
>its AutoPostback property to True. So that I can update database
>straight after user Check or Uncheck the Checkbox.
>
>I don't know how to capture the event when it postback after user has
>check/uncheck a specific checkbox, in order to update my database.
>
>Your help will be greatly appreiciated.
>
>Thanks a lot


Message sent from http://www.aewnet.com
 
Reply With Quote
 
 
 
 
Mike Moore [MSFT]
Guest
Posts: n/a
 
      10-24-2003
Hi Viny,

Since you have multiple check boxes that may have been modified, you will
need to iterate through all the entries in the grid. The following sample
starts with a datagrid with one template column containing a checkbox
control. It creates an array with four entries and binds to it to show four
empty check boxes. Whichever check boxes you select, clicking the button
shows the results.

In actual usage, you will need to have one of your columns be a unique
identifier so that you can update the correct data in your database.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Force "flow" layout
DataGrid1.Attributes.Remove("style")
Button1.Attributes.Remove("style")

If Not Page.IsPostBack Then
Dim MyList As New ArrayList
Dim i As Int32
For i = 0 To 3
MyList.Add(i)
Next
DataGrid1.DataSource = MyList
DataGrid1.DataBind()
Else
Dim i As Int32
For i = 0 To DataGrid1.Items.Count - 1
Dim ck As CheckBox
ck = DataGrid1.Items(i).Cells(0).FindControl("CheckBox1 ")
Response.Write(ck.Checked & "<br>")
'update the database here
Next
End If
End Sub

---
I hope this helps.

Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computerís security.

This posting is provided "AS IS", with no warranties, and confers no rights.


--------------------
> From: Viny <(E-Mail Removed)>
> References: <(E-Mail Removed) >
> X-Newsreader: AspNNTP 1.50 (aewnet.com)
> Subject: RE: Capture the Checkbox Event from DataGrid
> Mime-Version: 1.0
> Content-Type: text/plain; charset="us-ascii"
> Content-Transfer-Encoding: 7bit
> Message-ID: <(E-Mail Removed)>
> Newsgroups: microsoft.public.dotnet.framework.aspnet
> Date: Thu, 23 Oct 2003 06:14:09 -0700
> NNTP-Posting-Host: 63.161.67.199
> Lines: 1
> Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP11.phx.gbl
> Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:186032
> X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
>
>
> Hello,
> I am looking for the same things. Get the value of the checkbox and

update it to the database. Any help will be appreciated. I dont have a
update button in the datagrid. My update button is outside the datagrid.
> Thanks
> Viny
>
> >Hi Everyone,
> >My Datagrid has a TemplateColumn contains checkbox control and I set
> >its AutoPostback property to True. So that I can update database
> >straight after user Check or Uncheck the Checkbox.
> >
> >I don't know how to capture the event when it postback after user has
> >check/uncheck a specific checkbox, in order to update my database.
> >
> >Your help will be greatly appreiciated.
> >
> >Thanks a lot

>
> Message sent from http://www.aewnet.com
>


 
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
DataGrid and embeded Checkbox..How to find if checkbox clicked =?Utf-8?B?RG90TmV0RGV2?= ASP .Net 1 10-06-2006 04:11 PM
A gridview event/method to capture all checkbox.check states in this BoundColumn and Item_Bound grid? hazz ASP .Net 0 05-03-2006 06:10 PM
Howto bind CheckBox to the datagrid/ Then update the database field when the checkbox is clicked. Joey Pang ASP .Net Datagrid Control 4 06-13-2005 02:29 AM
Capture CheckBox Click Event news.microsoft.com ASP .Net Datagrid Control 1 12-16-2003 07:40 PM
Cannot capture a checkbox value in the DataGrid Petr Shekhtmeyster ASP .Net Datagrid Control 0 09-25-2003 10:27 PM



Advertisments