Column of tick boxes - how to do it?

J

John

Hi

I have a bound gridview. I need to allow users to select multiple rows and
then press the process button to process multiple selected rows. For this I
want to use additional column of checkboxes (unbound?) which user can tick.

Is there an example of such a scenario somewhere that I can have a look at?

Thanks

Regards
 
O

OHM \( One Handed Man \)

The solution ,

1.) Right Click on the datagrid in design view
2.) Choose Property Builder
3.)Choose Columns
4.) Add a template column
5.) OK, then right click over the grid again
6.)Choose Edit Template
7.) Select the template you just created
8.) Drag a checkbox to the Edit Item Template
9.) Give it a name you remember
A.) Right Click over the column and End Editing Templates

to use this you can iterate through the rows in the grid and for the
specific column with the checkbox in use the
..FindControl("YourCheckBoxName")

Voila !
 
J

John

Thanks. That is very useful. Just need a little hint on how to iterate the
grid and check for which checkboxes are ticked?

Thanks
 
O

OHM \( One Handed Man \)

'//Something like this.


Dim cb As CheckBox
For Each row As GridViewRow In GridView1.Rows
If row.RowType = DataControlRowType.DataRow Then
cb = CType(row.Cells(row.Cells.Count -
1).FindControl("ControlName"), CheckBox)
If cb.Checked Then
'//Do Something
End If
End If
Next
 
J

John

Feeling very stupid and sheepishly, I dare ask; Will this check only the
current page or all the records in the grid? I have pagination on the
gridview.

Thanks
 

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,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top