MAC
MAC

Reputation: 6577

checkbox data binding

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?

Upvotes: 0

Views: 598

Answers (1)

rahul
rahul

Reputation: 187040

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">

Upvotes: 1

Related Questions