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

telerik dropdownlist

7 Answers 76 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Santosh
Top achievements
Rank 1
Santosh asked on 19 Oct 2013, 11:28 AM
how to get values  from database into telerik dropdownlist ????

7 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 22 Oct 2013, 02:52 AM
Hi Santosh,

Please have a look into the following code snippet to get values from database in RadDropDownList.

ASPX:
<telerik:RadDropDownList ID="RadDropDownList1" runat="server" DataSourceID="SqlDataSource1"
    DefaultMessage="select" DataTextField="Cityname">
</telerik:RadDropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
    SelectCommand="SELECT [Cityname] FROM [City]">
</asp:SqlDataSource>

Thanks,
Shinu.
0
Santosh
Top achievements
Rank 1
answered on 22 Oct 2013, 07:00 AM
Thanks for the reply ..... Actually we are getting the values from database through data binding but it is not showing the value in page load itself when we click on dropdownlist values are present but by default in page load we are not getting dropdownlist value .  Is there any way to over come this issue .
0
Bozhidar
Telerik team
answered on 22 Oct 2013, 08:12 AM
Hi Santosh,

In the Page_Load event you have to explicitly call DataBind() on the DropDownList before you can access the items.
 

Regards,
Bozhidar
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 RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Santosh
Top achievements
Rank 1
answered on 04 Nov 2013, 04:58 AM
I use RadScheduler in my application...created resource collection and populated with some data.....but in the drop down by default the first list item is dispalyed as '-' which I dont want.I want default value irrespective of "-".

just few mins back seen ur reply to this kind of issue
This behavior is by design. If no resource of a specific type is associated with the appointment, the "-" option is selected for the dropdown list. (posted on dec 27 2007) ...... got any solution to this issue . 
0
Bozhidar
Telerik team
answered on 04 Nov 2013, 02:05 PM
Hi Santosh,

You can use the OnFormCreated event to get a reference to the resource ComboBox and change it's selected index. The event is described in the following help article:
http://www.telerik.com/help/aspnet-ajax/scheduler-formcreated.html

For example to preselect the first Resource of ResourceType Room in the AdvancedInsert form, you would write the following:
protected void scheduler_FormCreated(object sender, SchedulerFormCreatedEventArgs e)
{
    if (e.Container.Mode == SchedulerFormMode.AdvancedInsert)
    {
        RadComboBox combo = (RadComboBox)e.Container.FindControl("ResRoom");
        combo.Items[1].Selected = true;
    }
}

 

Regards,
Bozhidar
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 RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Santosh
Top achievements
Rank 1
answered on 05 Nov 2013, 04:45 AM
Thanks For the reply .... but we are using radresource(radresource types)  in radschedular.we want an default value instead of "-" and we don't want selected value to be placed instead of "-".For Detail we want "Active" text to be placed instead of "-" in Edit Appointment. Is their any way to solve this issue.
0
Bozhidar
Telerik team
answered on 07 Nov 2013, 08:09 AM
Hello Santosh,

The ComboBox is pre-populated with all the available resources, and the "-" item is added to indicate that no resource is selected. If you want to add a default value, it has to be one from the items already in the combo, otherwise it's going to be an invalid resource. If you don't want the "-" item to be visible, you can just set it"s Visibility property to false. 

If on the other hand you want to simply change it's text, so that you have a default item called "Active", which when selected specifies that the Appointment doesn't have any resources, you can again get a reference to this item and set its text.
 

Regards,
Bozhidar
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 RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
DropDownList
Asked by
Santosh
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Santosh
Top achievements
Rank 1
Bozhidar
Telerik team
Share this question
or