adding a checkbox to select the row.

R

rodrigo guerra

i'm using c#. code behind if possible.

i need a simple way to put a checkbox column in my datagrid and a button to
see witch rows are selected...

is there any big difference using checkbox and checkboxlist ? can i use
checkboxlist with a datagrid ?

thanks a lot.!!
 
T

Tim

if it is any help i can give you my code in vb and then you can work it out
into c# (btw. i don't use code-behind):

----------------------------------------------------------------------------
----------------------------------------
This Is Very Necessary You Will need This In Your Sub Page_Load
----------------------------------------------------------------------------
----------------------------------------

Sub Page_Load(obj as object, e as eventargs)
If Not IsPostBack Then
'DataBind Your DataGrid
End If
End Sub

----------------------------------------------------------------------------
----------------------------------------
You Will Need This Sub To Capture the Button Click
----------------------------------------------------------------------------
----------------------------------------

Sub IsChecked(ByVal sender As Object, ByVal e As EventArgs)
'Checkbox Information
Dim isDeleted As Boolean
Dim myDataGridItem As DataGridItem

' Check each box and see if the item should be deleted.
For Each myDataGridItem In CartDataGrid.Items
isDeleted = CType(myDataGridItem.FindControl("Delete"),
CheckBox).Checked
If isDeleted Then
Response.Write("Checked")
' Place any other code here
Else
Response.Write("Not Checked")
End If
Next
End Sub
 
R

rodrigo guerra

oh my god !!!
solved man... !! thank thanks...!!
if you were here in brazil i would pay you a beer !!

[]´s..

[ MVP ] Sukesh Ashok Kumar said:
Try this link and download gridtest.zip from my site for checkbox inside
grid...
http://v4cnet.europe.webmatrixhosting.net/

Rgds
Sukesh
Brain Behind - www.v4cnet.com


rodrigo guerra said:
i'm using c#. code behind if possible.

i need a simple way to put a checkbox column in my datagrid and a button to
see witch rows are selected...

is there any big difference using checkbox and checkboxlist ? can i use
checkboxlist with a datagrid ?

thanks a lot.!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top