Checkbox c#

Don
Joined
5 Oct 2005
Posts
11,239
Location
Liverpool
Hey All,

I'm trying to get a checkbox to automatically be checked depending on something but its not working, my code is:

if (Avail == "Yes")
{
CheckBoxAvail.Checked = true;
}
else
{
CheckBoxAvail.Checked = false;
}

any ideas why this is not working??

Stelly
 
string Avail = "Yes";

Response.Write(Avail);

if (Avail == "Yes")
{
CheckBoxAvail.Checked = true;
}
else
{
CheckBoxAvail.Checked = false;
}

That works fine... but this does not...

string Avail = Comp["Available"].ToString();

Response.Write(Avail);

if (Avail == "Yes")
{
CheckBoxAvail.Checked = true;
}
else
{
CheckBoxAvail.Checked = false;
}
 
whole code...
protected void Page_Load(object sender, EventArgs e)
{
int PCID = Convert.ToInt32(Request.QueryString["pcid"]);

DataSet CompSet = SQLQueries.CompDetailBindData(PCID);

string sPCIDValue = Convert.ToString(PCID);

if (!IsPostBack)
{


if (null != CompSet && 0 < CompSet.Tables[0].Rows.Count)
{
DataRow Comp = CompSet.Tables[0].Rows[0];

LabelCompModel.Text = Comp["PcModel"].ToString();
TextBoxCCCSR.Text = Comp["CCCSR"].ToString();
TextBoxEPSR.Text = Comp["EPSR"].ToString();
TextBoxShipDate.Text = Comp["ShipDate"].ToString();
LabelOnsite.Text = Comp["OnSite"].ToString();
LabelUser.Text = Comp["UserID"].ToString();

string Avail = Comp["Available"].ToString();

//string Avail = "Yes";

Response.Write(Avail);

if (Avail == "Yes")
{
CheckBoxAvail.Checked = true;
}
else
{
CheckBoxAvail.Checked = false;
}


}
}

}


Stelly
 
Back
Top Bottom