Binding checkbox with a dataset. - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Binding checkbox with a dataset.

Last post 05-25-2010 07:31 AM by lil me. 13 replies.
Page 1 of 1 (14 items)
Sort Posts: Previous Next
  • 01-04-2008 08:01 AM

    • cathy
    • Top 500 Contributor
    • Joined on 08-19-2007
    • Posts 38

    Binding checkbox with a dataset.

    Hi,

    I have an infopath  form that contains a drop down list and some checkboxes. I am maintianing a table in sql server 2000 with the same fields. (CustID (primary key) and some boolean values). I have created a data connection with sql server to bind the CustID with dropdown list. Now, my requirement is whenever the user selects the CustID from the drop down list, the infopath should get the values into checkboxes from the database table.  That means, whenever user selects CustID = 2, infopath should get data from " Select reviewreqd,chngdata.... from Customer where CustID = 2" where reviewreqd,chngdata etc fields are Boolean values in the table.  I was able to create a dataset with this select statement , but I don't know how to bind the checkbox in the infopath with the data from the data set.

    Any help in this regard is greately appreciated.

    Thanks

     

     

    Filed under: ,
  • 01-04-2008 08:59 AM In reply to

    Re: Binding checkbox with a dataset.

    Typically you would add a rule to the drop down with an action to set a field value.  You would select each checkbox and then set it to the value from your secondary connection with the filter custID = dropdown.

    You may want to check out the Database Accelerator, if you are working with SQL data.  It allows you to query and submit to multiple tables among other cool things. Qdabra Database Accelerator Suite Version 2.1 - Developer

    Filed under:
  • 01-04-2008 09:43 AM In reply to

    • cathy
    • Top 500 Contributor
    • Joined on 08-19-2007
    • Posts 38

    Re: Binding checkbox with a dataset.

    I have tried these rules before. When I am testing it in preview mode, whenever the rule applies, it is highlighting the checkbox with RED dots and giving me the error : Only 'true' or 'false' allowed.

    This field is a bit data type in sql server and it is returning 0 or 1 to the infopath. How can I fix this?

    Thanks

  • 01-04-2008 09:56 AM In reply to

    Re: Binding checkbox with a dataset.

    The problem is the missmatch between your SQL fields and the field types your checkboxes are bound to.  You need to change from boolean type field to number in InfoPath, the fields the check boxes are bound to, and then configure the check boxes to be 0 or 1 to match your SQL data.  That will get rid of your validation issues.  Currently they are only accepting true or false so the O and 1 are illegal.

  • 01-04-2008 11:19 AM In reply to

    • cathy
    • Top 500 Contributor
    • Joined on 08-19-2007
    • Posts 38

    Re: Binding checkbox with a dataset.

    I did exactly the same way you said above, now it is giving me error:  Only intergers are allowed.

    When I changed the values of checkbox as when cleared: 0 and when Selected : 1 (In the checkbox properties), it is giving me error: Only 0 or 1 allowed.

    so, does it mean that, Infopath is receiving data from sql server in some other format? (Other than true/false or 0/1?)

    Thanks

  • 01-04-2008 11:27 AM In reply to

    Re: Binding checkbox with a dataset.

    You may want to convert from whole number to text and then switch your checkboxes to text boxes and verify what you are receiving from SQL.

    You can have them as text boxes in InfoPath and still use 0 or 1 or whatever the value is for your checkbox.

     

  • 01-04-2008 11:53 AM In reply to

    • cathy
    • Top 500 Contributor
    • Joined on 08-19-2007
    • Posts 38

    Re: Binding checkbox with a dataset.

    When I have changed the checkbox data type to text(string) it looks working, but it is not showing the checkbox as checked when it gets 'true'  value from the database.

    Also it is raising an exception when I am trying to submit the form to sharepoint server. The error is

    Server was unable to read request ---> There is an error in xml document (1,594) .----> The string 'True' is not a valid boolean value.

     

  • 01-04-2008 11:59 AM In reply to

    Re: Binding checkbox with a dataset.

    I would change your checkboxes to text boxes and verify your values coming in from SQL.  Are they 0 and 1 or what?  Then makes sure you go into the check box properties and set the correct values for checked and unchecked.

    What is the column type in SQL?

  • 01-04-2008 12:13 PM In reply to

    • cathy
    • Top 500 Contributor
    • Joined on 08-19-2007
    • Posts 38

    Re: Binding checkbox with a dataset.

    The column type in SQL is bit.

    When I turned the checkbox to TextBox, it is receiving True/False from database.    (with the first letter as capital)

  • 01-04-2008 12:27 PM In reply to

    Re: Binding checkbox with a dataset.

    A bit is a 0 or 1.

    You have tried a boolean field with both true or false or 1 or 0 as the default?  I cannot find anything specific on using bit fields with InfoPath but it may not work since it is a specialized data field.

    I think you would need to change it in SQL to a char or int instead of a bit. I would think a conversion to an int would preserve the 1 and 0 values but you may want to test first.

  • 01-04-2008 01:23 PM In reply to

    • cathy
    • Top 500 Contributor
    • Joined on 08-19-2007
    • Posts 38

    Re: Binding checkbox with a dataset.

    I cannot change the data type in sql, because I am using web application to generate this table. I am directly binding the data (CustID,reviewreqd,changid....etc )(boolean fields)  using Details view control in that web application. Is there any other way changing it? How to get rid of this 'The string 'True' is not a boolean value' error?

    Thanks

     

  • 01-04-2008 01:30 PM In reply to

    Re: Binding checkbox with a dataset.

    You first need to figure out what SQL needs. I believe for a bit it should be a 1 or 0. Get submit working with that first.

    Then you set up your check boxes accordingly to use the correct values.

    Then when you set the fields for the check boxes from the secondary DC you perform a conversion if True set to 1 if False set to 0.

    I think that would be the only way to do it is to perform the translation in your form.

  • 01-07-2008 06:10 AM In reply to

    • cathy
    • Top 500 Contributor
    • Joined on 08-19-2007
    • Posts 38

    Re: Binding checkbox with a dataset.

    At last, I am able to submit the data with boolean values from sql server. I wrote the code in submit button to check for 'True/False' in Checkboxes.

    If (Checkbox.1.value="True")

    {

    Checkbox1.setvalue("TRUE");

    }

    Clay Fox, thanks for all your support. 

    I wonder, why this boolean value in SQL doesn't support the Boolean value in InfoPath, after all both are from Microsoft!!!!!

     

  • 05-25-2010 07:31 AM In reply to

    • lil me
    • Not Ranked
    • Joined on 05-25-2010
    • Posts 1

    Re: Binding checkbox with a dataset.

     

    I had this problem too and discovered that to set the fields value you needed to go into the fx then type "True" or "False" depending on which value you require.
Page 1 of 1 (14 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.