Checkbox functionality

Discussion in 'ASP .Net' started by =?Utf-8?B?QnJldA==?=, Dec 26, 2006.

  1. 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.
     
    =?Utf-8?B?QnJldA==?=, Dec 26, 2006
    #1
    1. Advertising

  2. 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.
     
    =?Utf-8?B?TWFuaXNoIEJhZm5h?=, Dec 27, 2006
    #2
    1. Advertising

  3. 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
     
    Rad [Visual C# MVP], Dec 27, 2006
    #3
  4. 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.
     
    =?Utf-8?B?TWFuaXNoIEJhZm5h?=, Dec 27, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tshad
    Replies:
    0
    Views:
    577
    tshad
    Apr 15, 2005
  2. Vikram

    disable checkbox list checkbox

    Vikram, Jan 25, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,429
    ThunderMusic
    Jan 25, 2006
  3. =?Utf-8?B?RG90TmV0RGV2?=

    DataGrid and embeded Checkbox..How to find if checkbox clicked

    =?Utf-8?B?RG90TmV0RGV2?=, Oct 6, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    863
    David Wier
    Oct 6, 2006
  4. Jason Huang
    Replies:
    0
    Views:
    583
    Jason Huang
    Jun 29, 2007
  5. Joey Pang
    Replies:
    4
    Views:
    562
    Joey Pang
    Jun 13, 2005
Loading...

Share This Page