Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C ASP.NET
Hello,
i have a checkbox in my gried view .
based on the value from my list i have to chekc or uncheck the checkbox.
as i have value like 1 or o if 1 the check or else uncheck. but its not working .
Please help.
List<user> lstusers = new List<user>();
            objDetails = new Details();
            lstusers = objDetails.getAllUsers();
            grdUserList.DataSource = lstusers;
            grdUserList.DataBind();
            foreach (GridViewRow row in grdUserList.Rows)
            {
                if (row.RowType == DataControlRowType.DataRow)
                {
                    CheckBox chk = new CheckBox();
                    chk = (CheckBox)row.FindControl("chkIsEnbled");
                    for (int i = 0; i < lstusers.Count; i++)
                    {
                        if (lstusers[i].isEnable == "1")
                        //if (row.Cells[5].Text == "1")
                        {
                            chk.Checked = true;
                        }
                        else
                        {
                            chk.Checked = false;
                        }
                    }
                }
            }</user></user>
Posted 1-Oct-12 2:56am
Edited 1-Oct-12 2:58am
JF201553.4K
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
 
You need to debug and check the value of lstusers[i].isEnable at run time. Is it "1" or some thing different like "true" or any other string?
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I think problem is with your following if condition
if (lstusers[i].isEnable == "1")
rest of the code seems to be ok.
Debug and check value of lstusers[i].isEnable at run time.
  Permalink  

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

  Print Answers RSS
0 Zoltán Zörgő 300
1 Peter Leow 150
2 BillWoodruff 120
3 CHill60 100
4 CPallini 80
0 Sergey Alexandrovich Kryukov 9,423
1 OriginalGriff 6,891
2 Peter Leow 4,692
3 Zoltán Zörgő 4,344
4 CHill60 2,932


Advertise | Privacy | Mobile
Web01 | 2.8.150129.1 | Last Updated 1 Oct 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100