By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,136 Members | 1,054 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,136 IT Pros & Developers. It's quick & easy.

checking a checkbox control at runtime based on literal value?

P: n/a
Hi,

Can I check a checkbox by default based on the value returned from a
database? for example if the value (dr("frm7value")) returned from a db
field is "YES" how can I check the checkbox by default?

Moe
Nov 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
yup in .Net u can bind any property to a data source
so in this case u would have to bind the checkbox selected property to that
particular field and it should give u the desired result (as long as the
field stores the correct value it requires)

"Moe Sizlak" <mo*@moe.com> wrote in message
news:eS**************@TK2MSFTNGP09.phx.gbl...
Hi,

Can I check a checkbox by default based on the value returned from a
database? for example if the value (dr("frm7value")) returned from a db
field is "YES" how can I check the checkbox by default?

Moe

---
Outgoing mail is certified Virus Free. (well i'd like to think it is.. )
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.723 / Virus Database: 479 - Release Date: 19/07/2004
Nov 18 '05 #2

P: n/a
Hi Mike,

Do you have any code samples to post?

Moe
"Mike Smith" <te**@test.com> wrote in message
news:uf**************@TK2MSFTNGP11.phx.gbl...
yup in .Net u can bind any property to a data source
so in this case u would have to bind the checkbox selected property to that particular field and it should give u the desired result (as long as the
field stores the correct value it requires)

"Moe Sizlak" <mo*@moe.com> wrote in message
news:eS**************@TK2MSFTNGP09.phx.gbl...
Hi,

Can I check a checkbox by default based on the value returned from a
database? for example if the value (dr("frm7value")) returned from a db
field is "YES" how can I check the checkbox by default?

Moe

---
Outgoing mail is certified Virus Free. (well i'd like to think it is.. )
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.723 / Virus Database: 479 - Release Date: 19/07/2004

Nov 18 '05 #3

P: n/a
ive got a demo (winForms) i did showing how to bind data to various
properties of controls (standard text, images and even the font color
property... )
was thinkin abt uploading it to planetsourcecode.com (just need to comment
the code nicely)

but what u need is to just bind the checkboxs selected property.

Scenario 1
If you already have the dataset on the designer u link it via the property
box.
1. Select the checkbox, browse the DataBinding property and link it to
the desired
DataSet.DataTable.Field

Scenario 2
If you are doing it thru code , then u need to write the databinding code
via.
CheckBox1.DataBindings.Add("Checked", Ds1,"Employees.Status")

where "Checked" is the property, DS1 is the datasource (dataset name) and
the Employees.Status is the datafield to be bound to (employees datatable
and Status field)

Note: I used a bit datatype for my Status field to be linked to the Checked
propery of the checkBox.

The above code is for winForms....
In asp.Net the equivalent would be the same for both Scenario 1 and 2 just
make sure DS1 is available prior to page load (page level declaration would
work):

<asp:CheckBox id="CheckBox1" runat="server" Checked='<%#
DataBinder.Eval(Ds1, "Tables[Employees].DefaultView.[0].Status") %>'>
</asp:CheckBox>
HTH..

Mike...
http://bikesh.europe.webmatrixhosting.net
http://www.planetsourcecode.com (search keyword : phoetus)
"Moe Sizlak" <mo*@moe.com> wrote in message
news:uj*************@TK2MSFTNGP11.phx.gbl...
Hi Mike,

Do you have any code samples to post?

Moe
"Mike Smith" <te**@test.com> wrote in message
news:uf**************@TK2MSFTNGP11.phx.gbl...
yup in .Net u can bind any property to a data source
so in this case u would have to bind the checkbox selected property to

that
particular field and it should give u the desired result (as long as the
field stores the correct value it requires)

"Moe Sizlak" <mo*@moe.com> wrote in message
news:eS**************@TK2MSFTNGP09.phx.gbl...
Hi,

Can I check a checkbox by default based on the value returned from a
database? for example if the value (dr("frm7value")) returned from a db field is "YES" how can I check the checkbox by default?

Moe

---
Outgoing mail is certified Virus Free. (well i'd like to think it is.. )
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.723 / Virus Database: 479 - Release Date: 19/07/2004


---
Outgoing mail is certified Virus Free. (well i'd like to think it is.. )
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.723 / Virus Database: 479 - Release Date: 19/07/2004
Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.