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 / December 2007

Tip: Looking for answers? Try searching our database.

Checkbox in a Datagrid, how to handle PostBack

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DotNetDev - 13 Dec 2007 18:00 GMT
Hi,

Does any one have an example of using Checkboxes in Datagrid?

I want to have postback enabled for each single checkbox and then execute
the code accordingly. Instead of having a button and looping through the list
of checkboxes to check if its clicked.
Angel - 13 Dec 2007 19:28 GMT
You need to create a template column for the field you wish to use as checkbox.
Replace the label and textbox with a checkbox the you will have to write
some code against it to retrieve the data

example:
Protected Sub Button1_Click(ByVal sender as Object, ByVal e as
System.EventArgs) handes Button1.Click

Dim myItem as DataGridItem = DataGrid1.Items(1)
dim myID as string = myItem.Cells.Item(0).Text
dim myProd as string = myItem.Cells.Item(1).Text
dim myChk as CheckBox = myItem.Cells.Item(2).FindControl("CheckBox2"),
CheckBox)

dim mybool as Boolean = myChk.Checked

Assumptions:
Retrieving three columns from Products table in Northwind
1 - ProductID
2 - ProductName
3 - Discontinued

Mounually bound these columns
convert the third into a templates

That's pretty much it.  

Signature

aaa

> Hi,
>
[quoted text clipped - 3 lines]
> the code accordingly. Instead of having a button and looping through the list
> of checkboxes to check if its clicked.

Rate this thread:







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.