Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
how to checked the row if checkbox is checked using multiple listviews of asp.net with c# .here my code is
C#
foreach (ListViewDataItem item in this.LstvCollegeCode.Items)
{
    if (item.ItemType == ListViewItemType.DataItem)
    {
        CheckBox chkbCollegeCode = item.FindControl("chkbCollegeCode") as CheckBox;
        if (chkbCollegeCode.Checked == true)
        {
            foreach (ListViewDataItem item1 in this.lstvCenterCode.Items)
            {
                CheckBox chkbCenterName = item.FindControl("chkbCenterName") as CheckBox;
                if (chkbCenterName.Checked == true)
                {

                    foreach (ListViewDataItem item2 in this.lstvCourse.Items)
                    {
                        CheckBox chkbCourse = item.FindControl("chkbCourse") as CheckBox;
                        if (chkbCourse.Checked == true)
                        {

                            SqlCommand cmd = new SqlCommand();
                            cmd = new SqlCommand("update HTStudentinfo set CenterCode='" + chkbCollegeCode + "',CenterName='" + chkbCollegeCode + "' where CollCode='" + chkbCollegeCode + "' and  Course='" + chkbCourse.Text + "' ", con);
                            DataSet ds = new DataSet();
                            cmd.CommandType = CommandType.Text;
                            SqlDataAdapter da = new SqlDataAdapter(cmd);
                            da.Fill(ds);
                            grdPrepare.DataSource = ds;
                            grdPrepare.DataBind();
                        }


[Edit member="Tadit"]
Corrected formatting and/or grammatical issues.
Added pre tags.
[/Edit]
Posted
v2
Comments
Sinisa Hajnal 21-Oct-14 2:21am    
What have you tried? What are you trying to do? The question shows conditional retrieval of the data depending on three-level-loop, but not which checkboxes should be set and depending on what data.

Please describe in more detail. Thank you.
What is the issue with the code?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900