By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,665 Members | 1,372 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,665 IT Pros & Developers. It's quick & easy.

Combine many Repeaters into 1

P: n/a
Roy
No errors here, I'm just looking for ways to make my code more
efficient. As the subject line suggests, I have a LOT of repeaters on a
certain page. They are visible or hidden depending on user actions and
are dispersed about the page via an "image map" style of GUI. The code
behind (and associated aspx) is below, you'll note that they all pull
from the same table and all virtually identical except for ID's and what
data they pull. How can I make this more efficient? Can I combine all
the repeaters into one and pull via a relation some-how? If so, how
would I do this?
THANKS

*****Code behind*****

Dim mycom1 As New SqlCommand("SELECT b.site, count(*)as cnt from cm_last
a right join theater b on a.loc_cd = b.geo_code where b.area = 'jar'
group by b.site", myconn)
Dim newadp1 As New SqlDataAdapter(mycom1)
Dim newds1 As New DataSet
newadp1.Fill(newds1, "one")
notesgrid1.DataSource = newds1.Tables("one").DefaultView
notesgrid1.DataBind()

Dim mycom2 As New SqlCommand("SELECT b.site, count(*)as cnt from cm_last
a right join theater b on a.loc_cd = b.geo_code where b.area = 'ncn'
group by b.site", myconn)
Dim newadp2 As New SqlDataAdapter(mycom2)
Dim newds2 As New DataSet
newadp2.Fill(newds2, "one")
notesgrid2.DataSource = newds2.Tables("one").DefaultView
notesgrid2.DataBind()

Dim mycom3 As New SqlCommand("SELECT b.site, count(*)as cnt from cm_last
a right join theater b on a.loc_cd = b.geo_code where b.area = 'trz'
group by b.site", myconn)
Dim newadp3 As New SqlDataAdapter(mycom3)
Dim newds3 As New DataSet
newadp3.Fill(newds3, "one")
notesgrid3.DataSource = newds3.Tables("one").DefaultView
notesgrid3.DataBind()

Dim mycom4 As New SqlCommand("SELECT b.site, count(*)as cnt from cm_last
a right join theater b on a.loc_cd = b.geo_code where b.area = 'lb1'
group by b.site", myconn)
Dim newadp4 As New SqlDataAdapter(mycom4)
Dim newds4 As New DataSet
newadp4.Fill(newds4, "one")
notesgrid4.DataSource = newds4.Tables("one").DefaultView
notesgrid4.DataBind()

Dim mycom5 As New SqlCommand("SELECT b.site, count(*)as cnt from cm_last
a right join theater b on a.loc_cd = b.geo_code where b.area = 'lrd'
group by b.site", myconn)
Dim newadp5 As New SqlDataAdapter(mycom5)
Dim newds5 As New DataSet
newadp5.Fill(newds5, "one")
notesgrid5.DataSource = newds5.Tables("one").DefaultView
notesgrid5.DataBind()

*****ASPX code*****

<div ID="note1" class="note">
<asp:repeater id="notesgrid1" Runat="server">
<HeaderTemplate>
Area 1
</HeaderTemplate>
<ItemTemplate>
<%#Container.DataItem("site")%> (<%# container.dataitem("cnt")%>)
</ItemTemplate>
<SeparatorTemplate><br></SeparatorTemplate>
</asp:repeater>
</div>

<div ID="note2" class="note">
<asp:repeater id="notesgrid2" Runat="server">
<HeaderTemplate>
Area 2
</HeaderTemplate>
<ItemTemplate>
<%#Container.DataItem("site")%> (<%# container.dataitem("cnt")%>)
</ItemTemplate>
<SeparatorTemplate>
<br>
</SeparatorTemplate>
</asp:repeater>
</div>

<div ID="note3" class="note">
<asp:repeater id="notesgrid3" Runat="server">
<HeaderTemplate>
Area 3
</HeaderTemplate>
<ItemTemplate>
<%#Container.DataItem("site")%> (<%# container.dataitem("cnt")%>)
</ItemTemplate>
<SeparatorTemplate>
<br>
</SeparatorTemplate>
</asp:repeater>
</div>

<div ID="note4" class="note">
<asp:repeater id="notesgrid4" Runat="server">
<HeaderTemplate>
Area 4
</HeaderTemplate>
<ItemTemplate>
<%#Container.DataItem("site")%> (<%# container.dataitem("cnt")%>)
</ItemTemplate>
<SeparatorTemplate>
<br>
</SeparatorTemplate>
</asp:repeater>
</div>

<div ID="note5" class="note">
<asp:repeater id="notesgrid5" Runat="server">
<HeaderTemplate>
Area 5
</HeaderTemplate>
<ItemTemplate>
<%#Container.DataItem("site")%> (<%# container.dataitem("cnt")%>)
</ItemTemplate>
<SeparatorTemplate>
<br>
</SeparatorTemplate>
</asp:repeater>
</div>

*** Sent via Developersdex http://www.developersdex.com ***
Mar 1 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Roy
Quick repost since no answers first time:
Anyone have any thoughts on this?
Thanks much.
From: Roy

No errors here, I'm just looking for ways to make my code more
efficient. As the subject line suggests, I have a LOT of repeaters on a
certain page. They are visible or hidden depending on user actions and
are dispersed about the page via an "image map" style of GUI. The code
behind (and associated aspx) is below, you'll note that they all pull
from the same table and all virtually identical except for ID's and what
data they pull. How can I make this more efficient? Can I combine all
the repeaters into one and pull via a relation some-how? If so, how
would I do this?
THANKS

*****Code behind*****

Dim mycom1 As New SqlCommand("SELECT b.site, count(*)as cnt from cm_last
a right join theater b on a.loc_cd = b.geo_code where b.area = 'jar'
group by b.site", myconn)
Dim newadp1 As New SqlDataAdapter(mycom1)
Dim newds1 As New DataSet
newadp1.Fill(newds1, "one")
notesgrid1.DataSource = newds1.Tables("one").DefaultView
notesgrid1.DataBind()

Dim mycom2 As New SqlCommand("SELECT b.site, count(*)as cnt from cm_last
a right join theater b on a.loc_cd = b.geo_code where b.area = 'ncn'
group by b.site", myconn)
Dim newadp2 As New SqlDataAdapter(mycom2)
Dim newds2 As New DataSet
newadp2.Fill(newds2, "one")
notesgrid2.DataSource = newds2.Tables("one").DefaultView
notesgrid2.DataBind()

Dim mycom3 As New SqlCommand("SELECT b.site, count(*)as cnt from cm_last
a right join theater b on a.loc_cd = b.geo_code where b.area = 'trz'
group by b.site", myconn)
Dim newadp3 As New SqlDataAdapter(mycom3)
Dim newds3 As New DataSet
newadp3.Fill(newds3, "one")
notesgrid3.DataSource = newds3.Tables("one").DefaultView
notesgrid3.DataBind()

Dim mycom4 As New SqlCommand("SELECT b.site, count(*)as cnt from cm_last
a right join theater b on a.loc_cd = b.geo_code where b.area = 'lb1'
group by b.site", myconn)
Dim newadp4 As New SqlDataAdapter(mycom4)
Dim newds4 As New DataSet
newadp4.Fill(newds4, "one")
notesgrid4.DataSource = newds4.Tables("one").DefaultView
notesgrid4.DataBind()

Dim mycom5 As New SqlCommand("SELECT b.site, count(*)as cnt from cm_last
a right join theater b on a.loc_cd = b.geo_code where b.area = 'lrd'
group by b.site", myconn)
Dim newadp5 As New SqlDataAdapter(mycom5)
Dim newds5 As New DataSet
newadp5.Fill(newds5, "one")
notesgrid5.DataSource = newds5.Tables("one").DefaultView
notesgrid5.DataBind()

*****ASPX code*****

<div ID="note1" class="note">
<asp:repeater id="notesgrid1" Runat="server">
<HeaderTemplate>
Area 1
</HeaderTemplate>
<ItemTemplate>
<%#Container.DataItem("site")%> (<%# container.dataitem("cnt")%>)
</ItemTemplate>
<SeparatorTemplate><br></SeparatorTemplate>
</asp:repeater>
</div>

<div ID="note2" class="note">
<asp:repeater id="notesgrid2" Runat="server">
<HeaderTemplate>
Area 2
</HeaderTemplate>
<ItemTemplate>
<%#Container.DataItem("site")%> (<%# container.dataitem("cnt")%>)
</ItemTemplate>
<SeparatorTemplate>
<br>
</SeparatorTemplate>
</asp:repeater>
</div>

<div ID="note3" class="note">
<asp:repeater id="notesgrid3" Runat="server">
<HeaderTemplate>
Area 3
</HeaderTemplate>
<ItemTemplate>
<%#Container.DataItem("site")%> (<%# container.dataitem("cnt")%>)
</ItemTemplate>
<SeparatorTemplate>
<br>
</SeparatorTemplate>
</asp:repeater>
</div>

<div ID="note4" class="note">
<asp:repeater id="notesgrid4" Runat="server">
<HeaderTemplate>
Area 4
</HeaderTemplate>
<ItemTemplate>
<%#Container.DataItem("site")%> (<%# container.dataitem("cnt")%>)
</ItemTemplate>
<SeparatorTemplate>
<br>
</SeparatorTemplate>
</asp:repeater>
</div>

<div ID="note5" class="note">
<asp:repeater id="notesgrid5" Runat="server">
<HeaderTemplate>
Area 5
</HeaderTemplate>
<ItemTemplate>
<%#Container.DataItem("site")%> (<%# container.dataitem("cnt")%>)
</ItemTemplate>
<SeparatorTemplate>
<br>
</SeparatorTemplate>
</asp:repeater>
</div>

*** Sent via Developersdex http://www.developersdex.com ***
Mar 2 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.