thenerdynerd
/
how-to-implement-cascaded-combo-box-columns-in-aspxgridview-without-using-templates-e3689
Public
forked from DevExpress-Examples/asp-net-web-forms-grid-cascaded-combo-box-columns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Default.aspx.vb
42 lines (36 loc) · 1.29 KB
/
Default.aspx.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Imports Microsoft.VisualBasic
Imports System
Imports DevExpress.Web
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If (Not IsPostBack) Then
Grid.StartEdit(0)
End If
End Sub
Protected Sub Grid_CellEditorInitialize(ByVal sender As Object, ByVal e As ASPxGridViewEditorEventArgs)
If e.Column.FieldName = "CityID" Then
Dim combo = CType(e.Editor, ASPxComboBox)
AddHandler combo.Callback, AddressOf combo_Callback
Dim grid = e.Column.Grid
If (Not combo.IsCallback) Then
Dim countryID = -1
If (Not grid.IsNewRowEditing) Then
countryID = CInt(Fix(grid.GetRowValues(e.VisibleIndex, "CountryID")))
End If
FillCitiesComboBox(combo, countryID)
End If
End If
End Sub
Private Sub combo_Callback(ByVal sender As Object, ByVal e As CallbackEventArgsBase)
Dim countryID = -1
Int32.TryParse(e.Parameter, countryID)
FillCitiesComboBox(TryCast(sender, ASPxComboBox), countryID)
End Sub
Protected Sub FillCitiesComboBox(ByVal combo As ASPxComboBox, ByVal countryID As Integer)
combo.DataSourceID = "Cities"
Cities.SelectParameters("CountryID").DefaultValue = countryID.ToString()
combo.DataBindItems()
combo.Items.Insert(0, New ListEditItem("", Nothing)) ' Null Item
End Sub
End Class