I have a DropDownList (have also tried ComboBox with the same results) that gets populated during page_load if it's not a post back. The code executes fine and the DropDownListItems are created and appear to be added from the code behind but when the page renders the DropDownList is empty/disabled. As soon as I do a post back (checkbox click), when it reloads, all of my DropDownLists now actually show the data and can be clicked on.
I've isolated this down to being caused when I load data into the DropDownList during page_load. On the post back, the data loading doesn't occur (as expected) and allows the items loaded from the initial page_load to be displayed.
Any ideas why this happens or what I can do to fix it? I've searched and searched but haven't found a solution that works. The ComboBox exhibits the exact same behavior.
Relevant code:
DropDownList markup:
page_load from code behind:
I've isolated this down to being caused when I load data into the DropDownList during page_load. On the post back, the data loading doesn't occur (as expected) and allows the items loaded from the initial page_load to be displayed.
Any ideas why this happens or what I can do to fix it? I've searched and searched but haven't found a solution that works. The ComboBox exhibits the exact same behavior.
Relevant code:
DropDownList markup:
<
telerik:RadDropDownList
ID
=
"cmbPayment_CardType"
runat
=
"server"
OnSelectedIndexChanged
=
"cmbPayment_CardType_SelectedIndexChanged"
Width
=
"160px"
DropDownHeight
=
"90px"
DropDownWidth
=
"160px"
/>
page_load from code behind:
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!IsPostBack)
{
List<
CreditCardListItem
> lstCreditCards = null;
//Load the list of accepted credit cards
cmbPayment_CardType.Items.Clear();
lstCreditCards = GetCreditCardsList();
if ((lstCreditCards != null) && (lstCreditCards.Count > 0))
{
foreach (CreditCardListItem ccDetails in lstCreditCards)
cmbPayment_CardType.Items.Add(new DropDownListItem() { Text = ccDetails.DisplayName, Value = ccDetails.DisplayOrder.ToString() });
}
lstCreditCards.Clear();
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.Print("Error: " + ex.ToString());
}
}
8 Answers, 1 is accepted
0
Hello Juan,
Could provide us with the implementation of the
Note : dll files are removed from the attachment.
Regards,
Nencho
the Telerik team
Could provide us with the implementation of the
GetCreditCardsList
() method, which is responsible for the population with data of the RadDropDownList? In addition, I have prepared a sample project for you, based on the provided snippet of code, demonstrating the behavior at my end. Could you give it a try and let me know if I had missed something.Note : dll files are removed from the attachment.
Regards,
Nencho
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0

J
Top achievements
Rank 1
answered on 26 Mar 2013, 02:40 PM
Here is the code from GetCreditCardList (it's from a separate DLL that was written in VB.NET):
I'll try to work up an example project for this soon. I know I owe you guys a couple example projects right now, but I've been super booked lately. Trying to get to it as soon as I have a chance. Some of the issues I've had to move on from and just replace with ASP.NET controls instead while we figure them out.
''' <summary>
''' Used to provide details about accepted credit cards.
''' </summary>
''' <remarks></remarks>
<Serializable()>
Public
Class
CreditCardListItem
Public
Property
DisplayName
As
String
=
String
.Empty
Public
Property
DisplayOrder
As
Byte
= 0
End
Class
''' <summary>
''' Gets the list of accepted credit cards.
''' </summary>
''' <returns>A List of CreditCardListItem objects detailing the credit cards that are accepted.</returns>
''' <remarks></remarks>
Public
Shared
Function
GetCreditCardsList()
As
List(Of CreditCardListItem)
Dim
ret_lstCards
As
List(Of CreditCardListItem) =
Nothing
Dim
cmdQuery
As
SqlCommand =
Nothing
Dim
drData
As
SqlDataReader =
Nothing
Dim
dbConn
As
SqlConnection =
Nothing
Try
dbConn =
New
SqlConnection(ConfigurationManager.ConnectionStrings(
"MasterDB"
).ConnectionString)
cmdQuery =
New
SqlCommand(
"Select * From CreditCardTYpes Order By TypeID, CardType"
, dbConn)
dbConn.Open()
drData = cmdQuery.ExecuteReader()
If
(drData.HasRows)
Then
ret_lstCards =
New
List(Of CreditCardListItem)
While
(drData.Read())
ret_lstCards.Add(
New
CreditCardListItem()
With
{.DisplayName = drData(
"CardType"
).ToString(), .DisplayOrder = drData(
"TypeID"
).ToString()})
End
While
End
If
Catch
ex
As
Exception
Debug.Print(
"ERROR: "
& ex.ToString())
Finally
'Clean up
If
(drData IsNot
Nothing
)
Then
drData.Close()
drData =
Nothing
End
If
If
(cmdQuery IsNot
Nothing
)
Then
cmdQuery.Cancel()
cmdQuery.Dispose()
cmdQuery =
Nothing
End
If
If
(dbConn IsNot
Nothing
)
Then
If
(dbConn.State <> ConnectionState.Closed)
Then
dbConn.Close()
End
If
dbConn.Dispose()
dbConn =
Nothing
End
If
End
Try
Return
ret_lstCards
End
Function
I'll try to work up an example project for this soon. I know I owe you guys a couple example projects right now, but I've been super booked lately. Trying to get to it as soon as I have a chance. Some of the issues I've had to move on from and just replace with ASP.NET controls instead while we figure them out.
0
Hello Juan,
The functionality implemented in the method looks correct. Please make sure that
Kind regards,
Nencho
the Telerik team
The functionality implemented in the method looks correct. Please make sure that
ret_lstCards List
is correctly populated with data and there are any exceptions, which might be caught by the Try Catch block. Did you have the chance to test the provided sample?Kind regards,
Nencho
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0

J
Top achievements
Rank 1
answered on 29 Mar 2013, 12:27 PM
It is correctly populated and no exceptions are raised. I 'fixed' the issue by just replacing it with a normal ASP.NET Dropdown List with no other changes.
I should have time today to get you guys the sample project to demonstrate what is happening.
And no, I hadn't had a chance to get back to this yet and try your sample.
I should have time today to get you guys the sample project to demonstrate what is happening.
And no, I hadn't had a chance to get back to this yet and try your sample.
0

J
Top achievements
Rank 1
answered on 10 Apr 2013, 02:39 PM
Not sure how, but this issue is fixed. I went to replace my normal ASP.NET drop down lists with the Telerik ones and this time around they worked properly. Not sure why, but it works so ... thanks.
0

John
Top achievements
Rank 1
answered on 26 Feb 2014, 01:59 AM
I have the exact same issue with Telerik context menus and Combo boxes. A postback is required before they display - even if the menu items or combobox items are explicitly defined in markup. Have not found a solution. I use Ironspeed Designer to create my apps and then customise them with Telerik controls.
0
Hello John,
Would you elaborate a bit more on the issue you are facing and which version of our controls you are currently using? In addition, please provide us with the implementation of the RadDropDownList that you use. Lastly, it would be best, if you could submit a support ticket, along with a runnable sample attached, which demonstrates the problem.
Regards,
Nencho
Telerik
Would you elaborate a bit more on the issue you are facing and which version of our controls you are currently using? In addition, please provide us with the implementation of the RadDropDownList that you use. Lastly, it would be best, if you could submit a support ticket, along with a runnable sample attached, which demonstrates the problem.
Regards,
Nencho
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
0

John
Top achievements
Rank 1
answered on 03 Mar 2014, 02:44 AM
Thanks Nencho. I tried to make a small bare-bones Ironspeed application that demonstrated the problem. In doing so, I worked out how to get around it. I had a radWindow and radContextMenu in the page and a radComboBox repeated in an HTML table on the same page.
By making the table a server-side table control and removing the radWindow altogether, the combobox and menu work perfectly without needing the first postback to populate.
There is a lot of code-behind and markup generated automatically by Ironspeed Designer. Sorry I don't have time to delve too deeply to work out what the interaction was that caused the problem.
By making the table a server-side table control and removing the radWindow altogether, the combobox and menu work perfectly without needing the first postback to populate.
There is a lot of code-behind and markup generated automatically by Ironspeed Designer. Sorry I don't have time to delve too deeply to work out what the interaction was that caused the problem.