Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2005

Tip: Looking for answers? Try searching our database.

CheckBox in DataGrid

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
James - 31 Oct 2005 21:43 GMT
I've added a template column to a DataGrid that contains a checkbox control.
The default value for this checked.  All items are checked on page load.  I
add a column to my dataset that contains a default value as well.  If a
record is unchecked in the grid, I need an event handler that can update the
dataset based on the ID or row.  Right now I can add a OnCheckedChanged
handler on the HTML side of things and get that event to fire...which is
defined like this:

Public Sub cbSendTo_CheckChanged(ByVal sender As Object, ByVal e As
EventArgs)
  ' what goes here?
End Sub

But I can't figure out how to refer to the specific record in the DataSet
without doing some weird concatenation on ItemDataBound and then parsing the
control's name...which is way too hokey (I hope).
Phillip Williams - 31 Oct 2005 22:13 GMT
Dim chk As CheckBox = CType(sender, CheckBox)
Dim dgItem As DataGridItem = CType(chk.NamingContainer, DataGridItem)
If not chk.Checked Then
    Dim dt As DataTable = Data_Table()
    Dim dr As DataRow = dt.Rows.Find(DataGrid1.DataKeys(dgItem.ItemIndex))
    If Not dr Is Nothing Then
        'do the processing
    End if

End If

You can see a demo on this link
http://www.societopia.net/samples/DataGrid_ChildControlsEvents.aspx
Signature

HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com

> I've added a template column to a DataGrid that contains a checkbox control.
> The default value for this checked.  All items are checked on page load.  I
[quoted text clipped - 12 lines]
> without doing some weird concatenation on ItemDataBound and then parsing the
> control's name...which is way too hokey (I hope).

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.