Solved

Zero bit value = Checked

Posted on 2010-08-26
3
430 Views
Last Modified: 2012-05-10
Hi,

The code below will display a checkbox as checked and show a table containing a text box if the bit value of a field in the db is a 1. If the bit value is 0, it will display just the checkbox as unchecked. I have several of these on the page and they work fine.

However, I now have the reverse things and show a checkbox as checked and a table containing a text box if the bit value is 0. In other words, a bit value of 0 will display the check box as checked and display the table containing the textbox. It is the opposite of the conditions described in the code below.

So, what changes do I need to make so that a 0 bit value will cause the checkbox to be checked and show the table containing the textbox?

Thanks!





Markup:

function RESReturnCurrentIns(chk) {
        ShowControl('tblRESReturnCurrentIns', chk.checked);
    }



                        <table > <tr >                          
                                    <td align="left"><asp:CheckBox ID="ckbRESReturnCurrentFlg"  runat="server"  Checked='<%# Bind("RESReturnCurrentFlg")%>' /></td>                                          
                                    <td width="100%">
                                        <table id="tblRESReturnCurrent" style="display:none">
                                            <tr>
                                               <td align="right"><asp:Label ID="lblRESReturnCurrent" style="vertical-align:middle;" runat="server" Text="Comment:" ></asp:Label>&nbsp;&nbsp;</td>
                                                <td align="left" ><asp:TextBox ID="txtRESReturnCurrentNotes" runat="server" Text='<%# Bind("RESReturnCurrentNotes") %>'></asp:TextBox></td>
                                             </tr>
                                        </table>
                                        </td>
                                </tr>                        
                            </table>



Code behind:


 Dim ckbRESReturnCurrentInsFlg As CheckBox = CType(CType(sender, FormView).FindControl("ckbRESReturnCurrentInsFlg"), CheckBox)
                If ckbRESReturnCurrentInsFlg IsNot Nothing Then
                    ckbRESReturnCurrentInsFlg.Attributes("onclick") = "RESReturnCurrentIns(this);"
                    If hasValue Then ScriptManager.RegisterStartupScript(Me, Me.GetType, "RESRtnIns", String.Format("RESReturnCurrentIns(document.getElementById('{0}'));", ckbRESReturnCurrentInsFlg.ClientID), True)
                End If




0
Comment
Question by:jaysch
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 400 total points
ID: 33538460
Try :

function RESReturnCurrentIns(chk) {
        ShowControl('tblRESReturnCurrentIns', !chk.checked);
    }

(we use an exclamation before chk.checked)
0
 

Author Closing Comment

by:jaysch
ID: 33544367
Works!

Thanks!!
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33544451
You're welcome! Thanks for the points!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now