Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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.
C#
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
Updated 1-Oct-12 1:58am
v2

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?
 
Share this answer
 
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.
 
Share this answer
 

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