• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 439
  • Last Modified:

Zero bit value = Checked

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
jaysch
Asked:
jaysch
  • 2
1 Solution
 
leakim971PluritechnicianCommented:
Try :

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

(we use an exclamation before chk.checked)
0
 
jayschAuthor Commented:
Works!

Thanks!!
0
 
leakim971PluritechnicianCommented:
You're welcome! Thanks for the points!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now