471,579 Members | 1,561 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,579 software developers and data experts.

Checkbox functionality

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.
Dec 27 '06 #1
3 2403
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.
"Bret" wrote:
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.
Dec 27 '06 #2
On Tue, 26 Dec 2006 15:53:00 -0800, Bret wrote:
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
--
Bits.Bytes
http://bytes.thinkersroom.com
Dec 27 '06 #3
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

"Bret" wrote:
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.
Dec 27 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Andy Lee | last post: by
3 posts views Thread by Fao, Sean | last post: by
1 post views Thread by Pramod | last post: by
7 posts views Thread by schaefty | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by Vinnie | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.