views:

91

answers:

1

How to add a check box in a .aspx page. I had used a database. and i read data from the database successfully. And now the readed data is in data table "dt". And i added this statement

if (dt.Rows[0]["IsActive"].ToString() == "True")

if the condition is true, Then the check box will be checked? but i didn't get. How it will get?

+1  A: 
if (dt.Rows[0]["IsActive"].ToString() == "True")
{
     chkAvtive.Checked = true;
}

chkActive is the id of your checkbox. Assuming the checkbox was already in the controls list in the page.

You can add a checkbox to your page using the following code

<input type="checkbox" id="chkActive" runat="server">
rahul
You mistyped the Checked property. It should be chkActive.Checked
Darin Dimitrov
Thanks, corrected the typo
rahul