Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
90
WebCombo 8.3: InitializeDataSource event handled from Repeater. (Paging)
posted

Hi. I need to know how to handle InitializeDataSource events from dynamically generated WebCombo boxes inside a repeater so that I can use paging.

My VB looks something like this:

  Private DataClasses As DataClassesDataContext
  Private EmpData As List(Of GetAllEmployeesResult)

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As  _
                          System.EventArgs) Handles Me.Load

    DataClasses = New DataClassesDataContext

    '***Set the repeater data source
    repeaterDisciplines.DataSource = DataClasses.GetAllDisciplines()
    repeaterDisciplines.DataBind()

    '***Set up the data source for the employee list
    EmpData = DataClasses.GetAllEmployees("").ToList()
    
    '***Reference all the webcombo boxes in the repeater to initialize them.
    For Each item As RepeaterItem In repeaterDisciplines.Items
      For Each ctl As Control In item.Controls()
        If TypeOf ctl Is Infragistics.WebUI.WebCombo.WebCombo Then
          Dim combo As Infragistics.WebUI.WebCombo.WebCombo = CType(ctl, Infragistics.WebUI.WebCombo.WebCombo)
          combo.DataSource = EmpData
          combo.EnableXmlHTTP = True
          combo.DropDownLayout.Pager.AllowPaging = True
          combo.DropDownLayout.Pager.PageSize = 20
          'How do I handle the InitializeDataSource event here?
        End If
      Next
    Next
  End Sub

My ASP looks something like this:

                  <asp:UpdatePanel ID="upRepeater" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
                    <ContentTemplate>
                      <asp:Repeater ID="repeaterDisciplines" runat="server" OnItemCommand="repeaterDisciplines_ItemCommand">
                        <ItemTemplate>
                          <tr>
                            <td class="tdLabel" style="text-align: left;"> <!--stuff--> </td>
                            <td class="tdInput">
                              <igcmbo:WebCombo ID="WebCombo1" runat="server" >
                              </igcmbo:WebCombo>
                            </td>
                            <td><!--stuff--></td>
                            <td><!--stuff--></td>
                          </tr>
                        </ItemTemplate>
                      </asp:Repeater>
                    </ContentTemplate>
                  </asp:UpdatePanel>

Thanks,

Dan Wahlstrom

 
Parents
  • 90
    posted

    Well, I figured out a way to handle the event by creating a new class that handles the InialiazeDataSource event

    Public Class BetterComboBox
      Inherits Infragistics.WebUI.WebCombo.WebCombo

      Sub CreateComboBox() Handles Me.InitializeDataSource

      End Sub
    End Class

     But the combo boxes aren't being populated by data. Any ideas? 

Reply Children
  • 90
    posted in reply to Dan

     I figured it out!

    I made a new control (BetterComboBox.ascx) by adding a new web user control to my project. This site was very helpful for that.

    I moved all the VB into that control

    Partial Public Class BetterComboBox1
      Inherits System.Web.UI.UserControl
      Private DataClasses As DataClassesDataContext
      Private EmpData As List(Of GetAllEmployeesResult)
      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        DataClasses = New DataClassesDataContext

        '***Set up the data source for the employee list
        EmpData = DataClasses.GetAllEmployees("").ToList()
        empList.DataSource = EmpData
        empList.EnableXmlHTTP = True
        empList.DropDownLayout.Pager.AllowPaging = True
        empList.DropDownLayout.Pager.PageSize = 20
        empList.DataBind()
      End Sub


      Private Sub empList_InitializeDataSource(ByVal sender As Object, ByVal e As Infragistics.WebUI.WebCombo.WebComboEventArgs) Handles empList.InitializeDataSource

      End Sub
    End Class

     After that it was only a matter of putting the proper references to the control and adding the new tag to the repeater

    <BCB:BetterCombo runat="server"></BCB:BetterCombo>

    Thanks!