Speed up my nested repeater!

  • Thread starter Thread starter ASF
  • Start date Start date
A

ASF

Hey all,

I have a gridview which pulls from a BLL which pulls from a DAL
(an .XSD file). Each row on that gridview has a nested repeater which
pulls from another table. The code which populates each nested
repeater is shown below (it's in the gridview's RowDataBound event).
My question is this: what can I do to speed up this process? Currently
EVERY time a new gridview row is generated the code reaches out to the
database, grabs the specific records for the nested repeater, and
closes the connection. This can be a huge overhead if many master
records are displayed.

Naturally my inclination is to grab ALL the records needed in one
database pull and then relate them in the codebehind, but I'm not sure
how to accomplish this given the current structure (with a DAL and
all).

Does anyone have any suggestions to increase efficiency here?



Protected Sub gvITV_RowDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.GridViewRowEventArgs) Handles
gvITV.RowDataBound

Dim nestedRepeater As Repeater =
TryCast(e.Row.FindControl("NR"), Repeater)
If nestedRepeater IsNot Nothing Then
Dim x As HiddenField = e.Row.FindControl("hdnID")
Dim con As SqlConnection = New
SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings("ConnectionString").ToString())

Dim sdap As SqlDataAdapter = New
SqlDataAdapter("dbo.Fsn_WEB", con)
sdap.SelectCommand.CommandType =
CommandType.StoredProcedure
sdap.SelectCommand.CommandTimeout = 0
sdap.SelectCommand.Parameters.Add("new_id", SqlDbType.Int)
sdap.SelectCommand.Parameters.Item(0).Value = x.Value

con.Open()
Dim dt As Data.DataTable = New Data.DataTable
sdap.Fill(dt)
con.Close()

nestedRepeater.DataSource = dt
nestedRepeater.DataBind()
End If
End Sub
 
ASF,

Any luck on that? I'm in the same boat. I read in this article
http://msdn.microsoft.com/en-us/library/aa992038.aspx where it mentions a
similar issue with nesting a gridview. It recommends caching for smaller
databases and using custom data object bound to an ObjectDataSource if your
database is large, but with no clear cut direction. I just posted to an
www.asp.net forum if you want to follow the thread.
http://forums.asp.net/t/1269591.aspx

If you found a good solution, please let me know!
 
Back
Top