?
Solved

Loop through checkboxes in listview control asp.net

Posted on 2008-11-04
2
Medium Priority
?
5,066 Views
Last Modified: 2013-12-17
I binding listview control with checkbox and populate from database like this.......

 <asp:ListView ID="List" runat="server" DataKeyNames="Id">
                        <LayoutTemplate>
                            <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
                        </LayoutTemplate>
                        <ItemTemplate>
                                <asp:CheckBox ID="ListCheckBoxField" runat="server" Text='<%#Eval("Description") %>' OnCheckedChanged="ListCheckBoxField_CheckedChanged" />
                        </ItemTemplate>                                              
                    </asp:ListView>

Now in code-behind how can I loop through all checked checkboxes and if checked then get id of checkbox ??
0
Comment
Question by:mugsey
2 Comments
 
LVL 4

Expert Comment

by:BToson
ID: 22875960
Going by your code, all of your checkboxes will have the same ID.
You will need to set the name to something unique maybe based on the data.
0
 
LVL 13

Accepted Solution

by:
sm394 earned 2000 total points
ID: 22876404
try something like this

foreach (ListViewItem item in myListView.Items)
    {
 CheckBox i = (CheckBox)item.FindControl("ListCheckBoxField");

           }
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Suggested Courses
Course of the Month8 days, 15 hours left to enroll

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question