This is a migrated thread and some comments may be shown as answers.

[Solved] Multiple Dropdowns on User Control (Grid Edit)

3 Answers 120 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin Andersen
Top achievements
Rank 1
Kevin Andersen asked on 20 Aug 2009, 07:28 PM
HI,

I am using a User Control to edit the grid values and the uc has 3 RadComboBox items (2008 Q1).  I am able to populate the first combo without a problem however when I add the code to the populate the second combo (and the third) it generates the error below:

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: Selection out of range
Parameter name: value

Source Error:

Line 700:        If Not IsPostBack Then
Line 701:            Me.rgPRResults.MasterTableView.Items(1).Edit = True
Line 702: Me.rgPRResults.MasterTableView.Rebind()Line 703:        End If
Line 704:

Here is the code for loading the combos...if I comment out the code to load the second combo it works fine but when it is uncommented it fails.  I used the Grid Edit via User Control demo as a template for this and made sure I set the datasource = nothing for the combos after loading the data but no luck.  Any thoughts?

Thanks in advance...

Kelvin

 

Protected Sub PriceRulesDetails_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.DataBinding

 

 

'Load Status DDL

 

 

Dim oValue As Object = DataBinder.Eval(DataItem, "Status").ToString

 

 

If oValue.Equals(DBNull.Value) Then

 

oValue =

""

 

 

End If

 

 

With Me.rdcmbPRStatus

 

.Items.Insert(0,

New RadComboBoxItem("", ""))

 

.Items.Insert(1,

New RadComboBoxItem("Active", "A"))

 

.Items.Insert(2,

New RadComboBoxItem("Inactive", "I"))

 

.DataBind()

 

End With

 

rdcmbPRStatus.SelectedValue = oValue.ToString

rdcmbPRStatus.DataSource =

Nothing

 

oValue =

Nothing

 

 

 

'Load Cost Multiplier DDL

 

oValue = DataBinder.Eval(DataItem,

"CostMultiplier").ToString

 

 

If oValue.Equals(DBNull.Value) Then

 

oValue =

""

 

 

End If

 

 

With Me.rdcmbPRCostMultiplier

 

.Items.Insert(0,

New RadComboBoxItem("", ""))

 

.Items.Insert(1,

New RadComboBoxItem("Program Cost", "P"))

 

.Items.Insert(2,

New RadComboBoxItem("Retail Cost", "R"))

 

 

End With

 

rdcmbPRCostMultiplier.SelectedValue = oValue.ToString

rdcmbPRCostMultiplier.DataSource =

Nothing

 

oValue =

Nothing

 

 

'' ''Load Reward Pricing Group DDL

 

 

' ''Me.rdcmbPRRewardPriceGroup.DataSource = LoadRewardPriceGroupsDDL()

 

 

' ''Me.rdcmbPRRewardPriceGroup.DataBind()

 

 

' ''oValue = DataBinder.Eval(DataItem, "RewardGroupID").ToString

 

 

' ''If oValue.Equals(DBNull.Value) Then

 

 

' '' oValue = ""

 

 

' ''End If

 

 

' ''rdcmbPRRewardPriceGroup.SelectedValue = oValue.ToString

 

 

' ''rdcmbPRRewardPriceGroup.DataSource = Nothing

 

 

' ''oValue = Nothing

 

 

 

End Sub

 

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 21 Aug 2009, 11:44 AM
Hi Kevin,

Can you verify using the debugger if there are any items in this grid? You are trying to access the first item.

Best wishes,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Kevin Andersen
Top achievements
Rank 1
answered on 21 Aug 2009, 11:53 PM
Hi Vlad,

Yes there are items in the Grid.  Since I don't have to access the items I removed the line of code that references it...now the page loads OK except that there are 2 identical sets of data in the dropdown when the Add Record is clicked.  The reason for this is the databinding handler is called twice...not sure when the second call is being generated as in the UC I have the following...your thoughts?

 

Protected Overrides Sub OnInit(ByVal e As EventArgs)

 

 

'

 

 

' CODEGEN: This call is required by the ASP.NET Web Form Designer.

 

 

'

 

InitializeComponent()

 

MyBase.OnInit(e)

 

 

End Sub 'OnInit

 

 

 

'/ <summary>

 

 

'/ Required method for Designer support - do not modify

 

 

'/ the contents of this method with the code editor.

 

 

'/ </summary>

 

 

Private Sub InitializeComponent()

 

 

AddHandler DataBinding, AddressOf Me.PriceRulesDetails_DataBinding

 

 

End Sub 'InitializeComponent

 


 

Protected Sub PriceRulesDetails_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.DataBinding

.............this is where the ddl's are loaded

End Sub

 

0
Sebastian
Telerik team
answered on 26 Aug 2009, 11:13 AM
Hello Kevin,

I suppose that the event is fired twice because you have AddHandler and Handles clause for the DataBinding handler of the user control at the same time. Does removing the Handles Me.DataBinding part from the event handler signature makes a difference?

Furthermore, verify that this line:

oValue = DataBinder.Eval(DataItem, "CostMultiplier").ToString

returns a valid value for item present in the Cost Multiplier DDL to be selected when specifying SelectedValue for that dropdown editor.

Best regards,
Sebastian
the Telerik team

returns a valid value for item present in the Cost Multiplier DDL to be selected when specifying SelectedValue for that dropdown editor.Best regards,the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Kevin Andersen
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Kevin Andersen
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or