Which way to use

HuaMin Chen
HuaMin Chen used Ask the Experts™
on
Hi,
Is it fine that we have a checkbox for the repeater list, thus we can do a "tick" for the relevant records? Or better we should use Gridview/listview for doing this?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
If a simple control can do that, what's point to use a complex control using more space, resource, code and even database access?

KISS - Keep it simple, stupid. :-)
you can use repeater list , no issues

also please find the attached image to undertans ahat all functionalities all this contorls support
will help you to select correct one
pr.jpg
HuaMin ChenProblem resolver

Author

Commented:
Which is better for this, among repeater, Gridview, Listview and etc?
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

Commented:
Repeater.

Any concerns for you to choose the others?
Listview

As it is providing other functionalities also
HuaMin ChenProblem resolver

Author

Commented:
Thanks all.
Peea,
I think it is a problem to have a checkbox within a repeater list as it is only a list of text items. If it is really fine to use a repeater, can you demonstrate it?

Commented:
FYI - not sure if you ever read this discussion.
HuaMin ChenProblem resolver

Author

Commented:
Hi,
Thanks. I think there is no way to use Repeater for this case right? If I assign a recordset to a repeater, how about the existing Checkbox within the repeater? Will there be no problem with it?
Scott FellDeveloper & EE Moderator
Fellow 2018
Most Valuable Expert 2013
Commented:
I am not a .NET dev but reading into that answer, it is calling for the rendered html to display the checkbox in a repeater and later to be collected to a hidden field you can capture.  I have created the front end sample using a text box instead of hidden for demonstration.
http://jsbin.com/padasQ_28376831/1/
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
  <script>
    $(function () {
    // listen for check/uncheck
    $('input.use_bold').change(function () {
        var collected_data_bold = [];
        $('input.use_bold').each(function () {
            if ($(this).is(':checked')) {
                collected_data_bold.push($(this).val());
            }
        });
        $('[name="collected_data_bold"]').val(collected_data_bold);
    });
    // listen for check/uncheck
    $('input.use_red').change(function () {
        var collected_data_red = [];
        $('input.use_red').each(function () {
            if ($(this).is(':checked')) {
                collected_data_red.push($(this).val());
            }
        });
        $('[name="collected_data_red"]').val(collected_data_red);
    });

});
    </script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <table id="mydata">
    <tr><td><input id="x1" name="x1" value="x1" type="checkbox" class="use_bold">Use Bold</td><td><input id="y1" name="y1" value="y1" type="checkbox" class="use_red">Use Red</td></tr> 
    
    <tr><td><input id="x2" name="x2" value="x2" type="checkbox" class="use_bold">Use Bold</td><td><input id="y2" name="y2" value="y2" type="checkbox" class="use_red">Use Red</td></tr>
  
    <tr><td><input id="x3" name="x3" value="x3" type="checkbox" class="use_bold">Use Bold</td><td><input id="y3" name="y3" value="y3" type="checkbox" class="use_red">Use Red</td></td></tr>

  </table>

  Bold<input name="collected_data_bold" type="text"><br>Red
  <input name="collected_data_red" type="text">
</div>
</body>
</html>

Open in new window

You can parse the data however you want to in the form post.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial