Solved

Zero bit value = Checked

Posted on 2010-08-26
3
435 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

749 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