Option Button problem with Web Service - InfoPath Dev
in

InfoPath Dev

Option Button problem with Web Service

Last post 06-05-2007 01:08 PM by Greg Collins. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 05-29-2007 09:58 AM

    Option Button problem with Web Service

    I have a SQL Server database with a table that has a field, discussedOutside, which is of type varchar(2).   I also have a web service that accesses that table, and in that service the class that defines the data to be returned to InfoPath has a field, discussedOutside, which has a type of string.  Finally, my InfoPath form has a pair of Option Buttons bound to data source field called discussedOutside.  This data source was created automatically when I created the form via the design a Form/Using a Data Connection/Web Service wizard.

    The problem is that when I hit the Run Query button, it populates all of the text boxes correctly from the database, but the option button for the discusedOutside field doesn't get set.  I have verified that the web service method corretly retrieves a Y from the database record, and I have set the "Value when selected" field for one of the option buttons to Y.  (The other one is set to N.)  Why doesn't this option button get selected?

    Any ideas on where I'm going wrong?  Many thanks.

  • 05-29-2007 12:21 PM In reply to

    Re: Option Button problem with Web Service

    It sounds like you've already checked this, but the quickest way to see what value is being returned is to place a text box in the view in place of the option buttons.

    But, what I'm guessing is that because you have varchar(2) in the database, that the WS is returning "Yx" where 'x' is some other unseen character (like a space character or something). This would create a mismatch for your option buttons. Why are you not using varchar(1) in SQL if you are only going to have a Y or N. For that matter, why not use a bit type with 1/0?

    Check (using code or conditional formatting) to verify that your WS returned value is really exactly "Y" and not some "Yx" as described above.

  • 06-05-2007 05:16 AM In reply to

    Re: Option Button problem with Web Service

    Thanks for your reply.  I tried making the database field a char(1) to avoid getting stray characters, but that didn't help.  I would think that varchar(n), where n is any integer, would just return the value in the database field, because that's what the "v" is for.  To get by this problem I converted the database field to "bit" and now it works.  But that doesn't solve the case of more than two radio buttons.  If each radio button can have a different value, and the values are of different lengths, what database type can you use other than varchar?

     

    Michael

  • 06-05-2007 01:08 PM In reply to

    Re: Option Button problem with Web Service

    For two-value controls (a checkbox or two radio buttons) a bit works great. For storing values of more significance, the varchar should work fine. I'm not sure why it isn't working for you. If the database stored varchar(10) with a value of "foo" and you are using a string on the InfoPath side, then you should be getting back exactly "foo" which should match your control.
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.