Forum
smartDBforms.NET for ASP.NET 2
 
 
Knowledge Base Forum
To post messages on the forum, you need to login first.
SearchForum Home
  Product Forums  smartDBforms.NET  Using Radiobutt...
 Re: Using Radiobutton list in smartdbforms
 
 6/9/2010 7:15:51 PM
David
10 posts


Re: Using Radiobutton list in smartdbforms

Would this be the same for dropdown lists?? I used the second option and the radiobuttonlist works fine now thanks...

I have a want to put a dropdown that looks up data from another table and binds to a filed on the insert form. i am using a different datasource for the dropdown and when i bind it to the field i get:

'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items.

Here is the query text for the dropdown:

SELECT DMData.DMUPI, DMData.DMFName, DMData.DMLName FROM CDFData RIGHT OUTER JOIN DMData ON CDFData.CDFDMUPI = DMData.DMUPI ORDER BY DMData.DMLName

INSERT INTO CDFData(CDFDMUPI) VALUES (@CDFDMUPI)

 

 

 6/10/2010 8:11:31 AM
Adillis Support
43 posts
adillis.com


Re: Using Radiobutton list in smartdbforms

Hi David,


Yes, you can use the same methods for the custom drop down list.

Only for the first method where additional ListItem is added, the ListItem can not be added statically because it will be overridden by the databinding against the additional data source.


Additional ListItem with 0 value can be added in two ways:

  • Add additional row in the dropdown list data source that will hold 0 value. This can be done with the SQL operator UNION, for example in your case:
    SELECT DMData.DMUPI, DMData.DMFName, DMData.DMLName DMData

    UNION SELECT 0 AS Expr1, '[NOT SET]' AS Expr2, '[NOT SET]' AS Expr3

    ORDER BY DMData.DMLName

  • The other way is using code to handle the DropDownList DataBound event which is fired after the dropdownlist is filled with data. In the event handler you can add a new ListItem
    protected void customDropDownList_DataBound(object sender, EventArgs e){
    customDropDownList.Items.Add(
    new ListItem("[NOT SET]", 0));
    }

If you have any other questions, we will be more than happy to help you.
Best wishes,
Adillis Support
Adillis - IT solutions http://adillis.com
 6/10/2010 2:50:50 PM
David
10 posts


Re: Using Radiobutton list in smartdbforms

Ok, I spoke too soon on the radiobuttonlist.

When I use the default value (suggestion 2 above) the control works when i test it until I submit the form...what is inserted is the default value not the selected choice????

Am I missing something

 6/10/2010 8:36:51 PM
David
10 posts


Re: Using Radiobutton list in smartdbforms
I found that i needed to delete the controlfield from the table in order for the Radiobtnlist to work.
 6/11/2010 1:52:21 AM
Adillis Support
43 posts
adillis.com


Re: Using Radiobutton list in smartdbforms
 Hi David,

Yes, you should check if there are another user interface elements that bind to the same field CDFQ1A. Also check if there is SmartDBControl that is also set to edit the CDFQ1A field.

If you find such UI elements that bind to the same field you should remove them because they override the value that is provided by your RadioButtonList during insert.

The logic is that if you have multiple user interface elements that edit the same DB field only the value from one of them will be used to save in database. The other will be overridden.

If you have any other questions, we will be more than happy to help you.
Best wishes,
Adillis Support
Adillis - IT solutions http://adillis.com


  Product Forums  smartDBforms.NET  Using Radiobutt...
Copyright 2006-2010 Adillis Terms Of Use Feedback Contact Us