Hi,
I'm having some problems with creating a custom filter control for something that I would assume is easy to do. I have created another in the project that is bound to a enum that works fine, but this filter which is bound to a class is failing:
The error
The markup
the custom control
The class (linq to sql)
Any ideas how I can resolve this issue?
I'm having some problems with creating a custom filter control for something that I would assume is easy to do. I have created another in the project that is bound to a enum that works fine, but this filter which is bound to a class is failing:
The error
The markup
<uc:OrderStatusFilterColumn AllowFiltering="true" AutoPostBackOnFilter="true" DataField="Status" HeaderText="Status" ShowFilterIcon="false" UniqueName="Status" > <ItemTemplate> <%# DirectCast(Container.DataItem, Quote).Status.Name%> </ItemTemplate></uc:OrderStatusFilterColumn>the custom control
Public Class OrderStatusFilterColumn Inherits GridTemplateColumn Protected Overrides Sub SetupFilterControls(ByVal cell As TableCell) Dim combo = New RadComboBox() combo.ID = "statusCombo" combo.AutoPostBack = True 'defaults combo.Items.Add(New RadComboBoxItem With {.Text = "All", .Value = "-1"}) For Each currentStatus As Status In Status.GetAllStatus() combo.Items.Add(New RadComboBoxItem With {.Text = currentStatus.Name, .Value = CStr(currentStatus.StatusID)}) Next AddHandler combo.SelectedIndexChanged, AddressOf comboSelectionChanged '-------------- cell.Controls.Add(combo) End Sub Private Sub comboSelectionChanged(ByVal sender As Object, ByVal e As RadComboBoxSelectedIndexChangedEventArgs) Dim combo = CType(sender, RadComboBox) Dim filterItem = TryCast(combo.NamingContainer, GridFilteringItem) filterItem.FireCommandEvent("Filter", New Pair()) End Sub Protected Overrides Sub SetCurrentFilterValueToControl(ByVal cell As TableCell) If Not String.IsNullOrEmpty(CurrentFilterValue) Then CType(cell.Controls(0), RadComboBox).Items.FindItemByValue(CurrentFilterValue).Selected = True End If End Sub Protected Overrides Function GetCurrentFilterValueFromControl(ByVal cell As TableCell) As String Dim currentValue = CType(cell.Controls(0), RadComboBox).SelectedItem.Value If String.IsNullOrEmpty(currentValue) Then CurrentFilterFunction = GridKnownFunction.NoFilter Return "-1" End If '---------------- If currentValue = "-1" Then CurrentFilterFunction = GridKnownFunction.NoFilter Else CurrentFilterFunction = GridKnownFunction.EqualTo End If Return currentValue End FunctionEnd ClassThe class (linq to sql)
<Global.System.Data.Linq.Mapping.TableAttribute(Name:="dbo.Status")> _Partial Public Class Status Implements System.ComponentModel.INotifyPropertyChanging, System.ComponentModel.INotifyPropertyChanged Private Shared emptyChangingEventArgs As PropertyChangingEventArgs = New PropertyChangingEventArgs(String.Empty) Private _StatusID As Integer Private _Name As String Private _Red As Integer Private _Green As Integer Private _Blue As Integer Private _SortOrder As Integer Private _QuoteHistories As EntitySet(Of QuoteHistory) Private _Quotes As EntitySet(Of Quote) #Region "Extensibility Method Definitions" Partial Private Sub OnLoaded() End Sub Partial Private Sub OnValidate(action As System.Data.Linq.ChangeAction) End Sub Partial Private Sub OnCreated() End Sub Partial Private Sub OnStatusIDChanging(value As Integer) End Sub Partial Private Sub OnStatusIDChanged() End Sub Partial Private Sub OnNameChanging(value As String) End Sub Partial Private Sub OnNameChanged() End Sub Partial Private Sub OnRedChanging(value As Integer) End Sub Partial Private Sub OnRedChanged() End Sub Partial Private Sub OnGreenChanging(value As Integer) End Sub Partial Private Sub OnGreenChanged() End Sub Partial Private Sub OnBlueChanging(value As Integer) End Sub Partial Private Sub OnBlueChanged() End Sub Partial Private Sub OnSortOrderChanging(value As Integer) End Sub Partial Private Sub OnSortOrderChanged() End Sub #End Region Public Sub New() MyBase.New Me._QuoteHistories = New EntitySet(Of QuoteHistory)(AddressOf Me.attach_QuoteHistories, AddressOf Me.detach_QuoteHistories) Me._Quotes = New EntitySet(Of Quote)(AddressOf Me.attach_Quotes, AddressOf Me.detach_Quotes) OnCreated End Sub <Global.System.Data.Linq.Mapping.ColumnAttribute(Storage:="_StatusID", AutoSync:=AutoSync.OnInsert, DbType:="Int NOT NULL IDENTITY", IsPrimaryKey:=true, IsDbGenerated:=true)> _ Public Property StatusID() As Integer Get Return Me._StatusID End Get Set If ((Me._StatusID = value) _ = false) Then Me.OnStatusIDChanging(value) Me.SendPropertyChanging Me._StatusID = value Me.SendPropertyChanged("StatusID") Me.OnStatusIDChanged End If End Set End Property <Global.System.Data.Linq.Mapping.ColumnAttribute(Storage:="_Name", DbType:="VarChar(50) NOT NULL", CanBeNull:=false)> _ Public Property Name() As String Get Return Me._Name End Get Set If (String.Equals(Me._Name, value) = false) Then Me.OnNameChanging(value) Me.SendPropertyChanging Me._Name = value Me.SendPropertyChanged("Name") Me.OnNameChanged End If End Set End Property <Global.System.Data.Linq.Mapping.ColumnAttribute(Storage:="_Red", DbType:="Int NOT NULL")> _ Public Property Red() As Integer Get Return Me._Red End Get Set If ((Me._Red = value) _ = false) Then Me.OnRedChanging(value) Me.SendPropertyChanging Me._Red = value Me.SendPropertyChanged("Red") Me.OnRedChanged End If End Set End Property <Global.System.Data.Linq.Mapping.ColumnAttribute(Storage:="_Green", DbType:="Int NOT NULL")> _ Public Property Green() As Integer Get Return Me._Green End Get Set If ((Me._Green = value) _ = false) Then Me.OnGreenChanging(value) Me.SendPropertyChanging Me._Green = value Me.SendPropertyChanged("Green") Me.OnGreenChanged End If End Set End Property <Global.System.Data.Linq.Mapping.ColumnAttribute(Storage:="_Blue", DbType:="Int NOT NULL")> _ Public Property Blue() As Integer Get Return Me._Blue End Get Set If ((Me._Blue = value) _ = false) Then Me.OnBlueChanging(value) Me.SendPropertyChanging Me._Blue = value Me.SendPropertyChanged("Blue") Me.OnBlueChanged End If End Set End Property <Global.System.Data.Linq.Mapping.ColumnAttribute(Storage:="_SortOrder", DbType:="Int NOT NULL")> _ Public Property SortOrder() As Integer Get Return Me._SortOrder End Get Set If ((Me._SortOrder = value) _ = false) Then Me.OnSortOrderChanging(value) Me.SendPropertyChanging Me._SortOrder = value Me.SendPropertyChanged("SortOrder") Me.OnSortOrderChanged End If End Set End Property <Global.System.Data.Linq.Mapping.AssociationAttribute(Name:="Status_QuoteHistory", Storage:="_QuoteHistories", ThisKey:="StatusID", OtherKey:="StatusID")> _ Public Property QuoteHistories() As EntitySet(Of QuoteHistory) Get Return Me._QuoteHistories End Get Set Me._QuoteHistories.Assign(value) End Set End Property <Global.System.Data.Linq.Mapping.AssociationAttribute(Name:="Status_Quote", Storage:="_Quotes", ThisKey:="StatusID", OtherKey:="StatusID")> _ Public Property Quotes() As EntitySet(Of Quote) Get Return Me._Quotes End Get Set Me._Quotes.Assign(value) End Set End Property Public Event PropertyChanging As PropertyChangingEventHandler Implements System.ComponentModel.INotifyPropertyChanging.PropertyChanging Public Event PropertyChanged As PropertyChangedEventHandler Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged Protected Overridable Sub SendPropertyChanging() If ((Me.PropertyChangingEvent Is Nothing) _ = false) Then RaiseEvent PropertyChanging(Me, emptyChangingEventArgs) End If End Sub Protected Overridable Sub SendPropertyChanged(ByVal propertyName As [String]) If ((Me.PropertyChangedEvent Is Nothing) _ = false) Then RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName)) End If End Sub Private Sub attach_QuoteHistories(ByVal entity As QuoteHistory) Me.SendPropertyChanging entity.Status = Me End Sub Private Sub detach_QuoteHistories(ByVal entity As QuoteHistory) Me.SendPropertyChanging entity.Status = Nothing End Sub Private Sub attach_Quotes(ByVal entity As Quote) Me.SendPropertyChanging entity.Status = Me End Sub Private Sub detach_Quotes(ByVal entity As Quote) Me.SendPropertyChanging entity.Status = Nothing End SubEnd ClassAny ideas how I can resolve this issue?