Checkbox functionality

G

Guest

I am a VB Developer w/ SQL Server experience breaking into web world via the
Visual Web Developer Express. I've already set up my data sources to my SQL
Server tables and have created a grid view of my tables which executes
successfully. Two of the fields in the gridview are checkboxes that are
bound to a table, datatype is "bit". These 2 fields are "APPROVED" or
"DENIED", in other words, the user needs to check approve or deny a record.
My question is what is the right or best way to accomplish this task,
gridview doesn't seem to accomplish this the way I'd like. Since a user can
potentially have 100 records to approve, I dont want them to have to EDIT
each record one by one and then UPDATE, I just want them to be able to click
each checkbox.
Please help.

thank you.
 
G

Guest

Hi,
I think ListView Control is more appropriate in your case.You will be able
to implement your functionality easily with ListView Control.
The ListView property CheckedIndices will give you a collection of integers
representing the indexes of all the checked items in the ListView.

ListView.CheckedIndexCollection checkedItems =
listView1.CheckedIndices;

while (checkedItems.Count > 0)
{
//your logic/code comes here
}

Also for selecting/Unselecting all items in ListView Control you just need
to provide one CheckBox above ListView Control and you can then run a loop in
its click event.
Although i have written chkSelectAllPMs_Click function in VB, you can easily
write same cose in C# or VB.NET with little modification.

Private Sub chkSelectAllPMs_Click()
If chkSelectAllPMs.Value Then
For i = 1 To ListView1.ListItems.Count
ListView1.ListItems(i).Checked = True
Next i
Else
For i = 1 To ListView1.ListItems.Count
ListView1.ListItems(i).Checked = False
Next i
End If
End Sub

You can search more about ListView Control in any search engine.
Hope this much helps you out.

Thanks and Regards,
Manish Bafna.
MCP and MCTS.
 
R

Rad [Visual C# MVP]

I am a VB Developer w/ SQL Server experience breaking into web world via the
Visual Web Developer Express. I've already set up my data sources to my SQL
Server tables and have created a grid view of my tables which executes
successfully. Two of the fields in the gridview are checkboxes that are
bound to a table, datatype is "bit". These 2 fields are "APPROVED" or
"DENIED", in other words, the user needs to check approve or deny a record.
My question is what is the right or best way to accomplish this task,
gridview doesn't seem to accomplish this the way I'd like. Since a user can
potentially have 100 records to approve, I dont want them to have to EDIT
each record one by one and then UPDATE, I just want them to be able to click
each checkbox.
Please help.

thank you.

You could also loop through each datagrid item, find the checkbox and check
if it is checked or not and then execute your custom logic
 
G

Guest

Hi,
Only reason why i was insisting on ListView as compared to Datagrid was
because ListView is much lightweight than DataGrid and so performancewise it
would be good for you.I think you easily implement your funtionality with
ListView because you just want checkboxes.For which you just need to set one
property in ListView Control.

Thanks and Regards,
Manish Bafna.
MCP and MCTS
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top