Asked by:
How to show the value of a Checkbox in a control

Question
-
User380413204 posted
Hi All,
Installed Franks Bulk Emailer, works like a charm. But I wanted to adapt it a little bit to my needs:
This is what I try to do:
Users when they register can check a Checkbox when they want to receive a Newsletter. (Datatype bit)
When I use the Bulk Emailer only the users that Checked that box on registering will be sent an e-mail.
Also added a Checkbox to Member_Details (where Users can change their Userinfo)
This Checkbox must of course show the value that is stored in the Database.
I believe the Controls on that page are filled with:
Sub InitPageData() Dim user As MembershipUser = Membership.GetUser() Dim da As New DataSetTableAdapters.MemberInfoTableAdapter Dim dt As DataSet.MemberInfoDataTable = da.GetMember(CType(user.ProviderUserKey, Guid)) If dt.Rows.Count = 1 Then Dim mr As DataSet.MemberInfoRow = dt(0)UserName.Text = user.UserName
fname.Text = mr.firstname
lname.Text = mr.lastname
Email.Text = user.Email
Addr.Text = mr.address
Phone.Text = mr.phone
If
mr.IsNewsletterNull ThenNieuwsbrief.Checked =
False ElseNieuwsbrief.Checked =
True End IfWith these last lines I try to show the value, but to no avail.
What am I doing wrong here?
Thanks,
Lex
Monday, June 5, 2006 1:55 PM
All replies
-
User2069888697 posted
If your trying to pass the value to the memberinfo table
NewsletterValue = CheckBoxName.SelectedValue.ToString
NewsletterValue being the column name in the database
This will send either a 1 or 0 to the database.
Therefore there should not be a null value in the database.
0=false and 1= true
What you have written will show it as checked because 0 is not a null value.
You did not specify whether the box is showing to always be checked so maybe this will help.
btw I am modifing the original Bulk emailer page to allow role specific emails and also thanks to Marks suggestions change the way the emails actually go out. Currently they all go out as individual emails and when you have alot of members this can put a burden on your server. (I have 54 members and it takes approx. 20 sec to send the emails.) I will be modifing it to use BCC, that way the website server sends out less emails and your actual email server BCC's the members. This will take me a few days, as Mark mentioned some email servers limit the amout of BCC's so it will need to take that into consideration.
Monday, June 5, 2006 2:58 PM -
User2069888697 posted
Hi lex,
I just threw together a page that allows members to add or remove themselves from the mailing list
It uses a role to accomplish it, this makes it easy to implement.
Just add a role named EmailList
The Label and button on the aspx page can then be placed in your memberinfo page and the vb can be moved into the script and it will work.
I will post it on my site shortly, any questions email me.
Monday, June 5, 2006 3:41 PM -
User380413204 posted
Hi Frank,
Great, I think that is exactly what I am looking for.
Lex
Monday, June 5, 2006 4:11 PM