Solved

Zero bit value = Checked

Posted on 2010-08-26
3
436 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

690 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