Hi David
The easiest way to have radiobutton list is to create it inside SmartDBView and to two-way databind its SelectedValue property to the proper db field. The radiobutton list items should the items which can be inserted. The value of the items will be the actual value that will be inserted in the db field when the SmartDBView form is saved.
For example the following radiobutton list is bound to an integer db field SupplierID which and can insert values from 1 to 7.
<asp:RadioButtonList ID="radioSupplier" runat="server" SelectedValue='<%# Bind("SupplierID") %>'
Enabled='<%# !Container.IsReadOnlyMode %>'>
<asp:ListItem Value="1">Exotic Liquids</asp:ListItem>
<asp:ListItem Value="2">New Orleans Cajun Delights</asp:ListItem>
<asp:ListItem Value="3">Grandma Kelly's Homestead</asp:ListItem>
<asp:ListItem Value="4">Tokyo Traders</asp:ListItem>
<asp:ListItem Value="5">Cooperativa de Quesos 'Las Cabras'</asp:ListItem>
<asp:ListItem Value="6">Mayumi's</asp:ListItem>
<asp:ListItem Value="7">Pavlova, Ltd.</asp:ListItem>
</asp:RadioButtonList>
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
Here is the code and error I get:
<
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: 'RadioButtonList1' has a SelectedValue which is invalid because it does not exist in the list of items.Parameter name: valueSource Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
When in Insert mode the children are databound against default values. In this case the default value for integer db field will be 0. The error appears because during initial databinding the CDFQ1A field has value 0 and the RadioButtonList does not have ListItem with Value 0.
You can resolve this in one of the following ways:
You can add one more ListItem with Value 0. This will be the initially selected ListItem
You can change the default value of CDFQ1A during Insert. This can be done in the following way – Open the SmartDataSource for the form. Select the Insert tab. In the Parameters list click the CDFQ1A parameter. On the right-hand side you will see DefaultValue field. Put the value you desire, for example 1 – this will select the last ListItem in your example.
The last way requires one line of code. Remove the SelectedValue='<%# Bind("CDFQ1A") %> expression from your RadioButtonList. In this way the SelectedValue attribute will not be databound and there will be no exception. But now the value is also not extracted during save time. You should put code to extract the selected value during save. Create event handler for the SmartDBView.ValuesExtracted event. In the event handler put the following code to extract the selected value:protected void SmartDBView1_ValuesExtracted(SmartDBView sender, SmartDBViewExtractedArgs e){ e.Values["CDFQ1A"] = RadioButtonList1.SelectedValue;}
If you have any other questions, we will be more than happy to help you.Best wishes,Adillis SupportAdillis - IT solutions http://adillis.com