Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I've created a user control (.ascx). This user control contains an HTML table with one table row, three table details. The first TD contains an ASP Label control. The second contains a RadioButtonList with two options ("New", "Existing"). The third contains a DropDownList. In the .ascx control, the Label's text is set using a Public Property of type String, and the DropDownList's data source is set by a Public Property of type SqlClient.SqlDataReader. The reader will return about 6100 customers. The radio buttons are static.

 

I am using this control on an .aspx page with a GridView and an empty Panel control. When I click on "select" in the GridView, I create my user control and add it to the Panel control. So far, I only add one user control. I will need to add more after I figure out the answer to my problem.

 

The first time I click "select" in the GridView, the user control takes about two seconds to show up on the page. That's fine. However, if I click another item in the GridView, the browser locks up for about a minute. Stepping through the code, I can reach the "End Sub" of the event "myGridView_SelectedIndexChanged(). However, stepping past this End Sub locks up the browser. There is no other VB code running after that End Sub or after the lock up.

 

I really have no idea what is going on here. I should note that I am using AJAX, so all of the above-mentioned controls are in an AJAX UpdatePanel. One other note, IE locks up for about a minute, but Firefox locks up for about 5 seconds (which is still longer than clicking the GridView the first time). Another caveat ... this control is going to be used to determine if a customer in the GridView (coming from an ERP system) is already in "our" SQL Server database, so all of "our" customers have to be in one DropDownList. The SqlDataReader assigned to the DropDownList comes from "our" database.

 

I don't want to post a whole slew of code, so I'll just start with the GridView event and the user control creation:

Private Sub gvNewCustomers_SelectedIndexChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles gvNewCustomers.SelectedIndexChanged
       Try
           Dim sCustID As String
           Dim sCustName As String

           sCustID = Me.gvNewCustomers.SelectedRow.Cells(2).Text
           sCustName = Me.gvNewCustomers.SelectedRow.Cells(3).Text

           Call AddDynamicControls(sCustID, sCustName)

       Catch ex As Exception
           Throw
       End Try
End Sub '  ***** Freezes here (the last line of code before the page renders)

Private Sub AddDynamicControls(ByVal custId As String, ByVal custName As String)
       Try
           ' Clear out the Placeholder of any existing controls.
           Me.pnlDynamicControls.Controls.Clear()

           ' Add the customer control
           Call AddCustomerDynamicControls(custId, custName)

           ' Add an HTML Horizontal row
           Me.pnlDynamicControls.Controls.Add(New HtmlGenericControl("hr"))

           ' TODO: Add the address controls

       Catch ex As Exception
           Throw
End Sub

Private Sub AddCustomerDynamicControls(ByVal custId As String, ByVal custName As String)
       Try
           Dim oEntity As Control = LoadControl("EntitySelector.ascx")

           CType(oEntity, EntitySelector).ID = "entity_Cust_" & custId
           CType(oEntity, EntitySelector).LabelText = custName
           CType(oEntity, EntitySelector).DropDownDataSource = CreateCustomerDataReader()
           Me.pnlDynamicControls.Controls.Add(oEntity)

       Catch ex As Exception
           Throw
       End Try
   End Sub

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...