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

Filter DataGrid From RadCombo Boxes

2 Answers 76 Views
Grid
This is a migrated thread and some comments may be shown as answers.
waseem
Top achievements
Rank 2
waseem asked on 16 Nov 2008, 08:36 AM
Dear!

i have to RadCombo Boxes first cmbCountry, and send cmbCity, I need to display Hotels in RadGrid depending on Comboxes. What i have to do for loading the Data in RadGrid?

i have doubt on selected index change event of City Combo Box, but i am not sure how to use this.....

ASP.NET 2.0
RADControls ASP.NET AJAX Q2 2008
OS:Vista

<telerik:RadComboBox ID="cmbCountry" Runat="server" Skin="Hay" OnItemsRequested="cmbCountry_ItemsRequested" OnClientSelectedIndexChanging="LoadCities" MarkFirstMatch="true" HighlightTemplatedItems="true" >

<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>

</telerik:RadComboBox>



<telerik:RadComboBox ID="cmbCity" Runat="server" Skin="Hay" OnItemsRequested="cmbCity_ItemsRequested" OnSelectedIndexChanged="LoadHotels" MarkFirstMatch="true" HighlightTemplatedItems="true" >

<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>

</telerik:RadComboBox>


Sub LoadCountries()

Dim A As New Telerik.Web.UI.RadComboBoxItem


A.Text = "---Select Country---"


With cmbCountry

.DataTextField = "Country_Name"

.DataValueField = "Country_ID"

.DataSource = objCountry.AllCountriesByReader

.DataBind()


End With


cmbCountry.Items.Insert(0, A)


End Sub



Sub LoadCities(ByVal CountryID As String)
Dim A As New Telerik.Web.UI.RadComboBoxItem


A.Text = "---Select City---"


If String.IsNullOrEmpty(CountryID) = True Then Exit Sub

objCity.CnID = CType(CountryID, Integer)


With cmbCity
.DataTextField = "City_Name"

.DataValueField = "City_ID"

.DataSource = objCity.AllCitiesByCnID

.DataBind()

End With

End Sub

2 Answers, 1 is accepted

Sort by
0
waseem
Top achievements
Rank 2
answered on 17 Nov 2008, 04:50 AM

 

Protected Sub LoadHotels(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles   cmbCity.SelectedIndexChanged

 

    BoundGrid()

 

End Sub

 

 

 

 

Sub BoundGrid()

 

 

Dim objhotel As New PakiSoft.Hotels.HotelDB

 

objhotel.CountryId = cmbCountry.SelectedValue

objhotel.CityID = cmbCity.SelectedValue

RadGrid1.DataSource = objhotel.AllHotels

RadGrid1.DataBind()

 

 

End Sub

 

0
Sebastian
Telerik team
answered on 18 Nov 2008, 01:55 PM
Hi waseem,

Your implementation of the SelectedIndexChanged handler seems correct and the code should populate the grid instance with the relevant hotels info. Can you please verify that the SelectedIndexChanged event is raised as expected in this case?

An alternative approach would be to use data source controls and select parameters for them as demonstrated in this online demo:

http://demos.telerik.com/ASPNET/Prometheus/Controls/Examples/Integration/GridComboAjax/DefaultCS.aspx?product=grid

Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
waseem
Top achievements
Rank 2
Answers by
waseem
Top achievements
Rank 2
Sebastian
Telerik team
Share this question
or