HOW TO FOUND CHECKBOX ID

jayprakash sharma

Total Post:117

Points:821
Posted by  jayprakash sharma
C# 
 888  View(s)
Ratings:
Rate this:

I want to check a checkbox after finding that it is checked in database. I'm trying this:

string chkboxbit = String.Empty;

CheckBox cb = new CheckBox();

chkboxbit = "ct100$ContentPlaceHolder1_chk" + item + "" + i;

cb = (CheckBox)Page.FindControl(chkboxbit.ToString());

cb.Checked = false;

But I'm getting cb value null on debugging.

  1. Pravesh Singh

    Post:101

    Points:709
    Re: How to found CheckBox ID

    Hi jay


    I got it... and it works fine...

    chkboxbit = "chk" + item + "" + i;

    ContentPlaceHolder cph = (ContentPlaceHolder)this.Master.FindControl("ContentPlaceHolder1");

    cb = ((CheckBox)cph.FindControl(chkboxbit));

    if (cb != null)

        cb.Checked = false;

    Thnks to all for their effort. and Thanks Kyojimaru.

      Modified On Apr-12-2016 12:14:44 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!