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

UserControl event fires but properties are empty

1 Answer 39 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Johnathan
Top achievements
Rank 1
Johnathan asked on 08 Dec 2010, 06:01 PM
Hi

I have a simple grid with no edit mode. See Pic at this URL
http://screencast.com/t/X1XtwRegixy

I want the user to be able to switch "Chart" without going into an edit mode.

I therefore created a user control made from a a radcombo which populates the combo and has an event attached to it which calls a method that updates the charttype in the database.

I have an additional property in my usercontrol which is the Primarykey (seriesID) required create the obj and run the update.

<telerik:GridTemplateColumn HeaderText="Chart" UniqueName="ColChart">
                                     <ItemTemplate>
                                     <uc3:kpidropdownchart ID="kpiDropDownChart1" runat="server" seriesid='<%#Bind("SeriesID") %>' selectedChart='<%#Bind("ChartType") %>'/>
                                     </ItemTemplate>
                                     </telerik:GridTemplateColumn>

The control populates correctly (I even added the primarykey into the item.text to show it is there - see pic above)
When The selected index is changed the event fires (pasisng all of the argument including old and new values) inside the user control, but all of the properties in the usercontrol now are empty ie the primaryKey (seriesID) required to run call my update method.


Any idea what I am doing wrong?

Imports Telerik.Web.UI
  
Public Class kpiDropDownChart
    Inherits System.Web.UI.UserControl
    Private _seriesid As Integer
    Private _selectedChart As String
    Private _chartid As Integer
  
    Public Property SeriesID() As Integer
        Get
            Return (_seriesid)
        End Get
        Set(ByVal value As Integer)
            _seriesid = value
        End Set
    End Property
    
    Public Property selectedChart() As String
        Get
            Return (_selectedChart)
        End Get
        Set(ByVal value As String)
            _selectedChart = value
        End Set
    End Property
  
  
    Protected Sub ddAddFieldChart_PreRender(ByVal sender As Object, ByVal e As EventArgs) Handles ddAddFieldChart.PreRender
        Dim chartTypeTable As DataTable = kpicommonListFns.GetTimeChartList
        Dim row As DataRow
        For Each row In chartTypeTable.Rows
            Dim CItem As RadComboBoxItem = New RadComboBoxItem
            CItem.Text = row("Description") & _seriesid
            CItem.Value = row("chartRef")
            CItem.ImageUrl = "~/images/chartImages/" & row("IconName")
            ddAddFieldChart.Items.Add(CItem)
        Next
        ddAddFieldChart.SelectedValue = _selectedChart
    End Sub
  
    Private Sub ddAddFieldChart_SelectedIndexChanged(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles ddAddFieldChart.SelectedIndexChanged
  
        '###### when this even fires _seriesid = nothing ####################
        Dim thisSeries As kpiChartSeries = New kpiChartSeries(_seriesid)
        thisSeries.SetChartType(ddAddFieldChart.SelectedValue)
    End Sub
End Class


Thanks

johnathan

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 15 Dec 2010, 09:52 AM
Hello Johnathan,

If I understand your scenario properly, you have to persist the SeriesID / selectedChart properties as demonstrated in the following code-snippet:
Public Property SeriesID() As Integer
    Get
        Return CInt(ViewState("_seriesid"))
    End Get
    Set
        ViewState("_seriesid") = value
    End Set
End Property
 
Public Property selectedChart() As String
    Get
        Return ViewState("_selectedChart").ToString()
    End Get
    Set
        ViewState("_selectedChart") = value
    End Set
End Property

Regards,
Daniel
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Johnathan
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or