Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem Displaying Data Using Repeater Control

Status
Not open for further replies.

cyberstore05

Programmer
Jan 4, 2008
2
GB
Hi There,
I am trying to display data from an SQL database using the Repeater control in ASP.net, but I’ve run into some difficulty. Primarily, when a user selects an item from a menu, data from an SQL table is displayed using Gridview – this works perfectly ok. Additionally, I want a subset of the Gridview data to be displayed using the Repeater control - this is where I have the problem: the two sets of data are not displayed simultaneously when a menu selection is made. Instead, the data from the previous menu selection is displayed. In short, the Repeater data lags behind the Gridview data.

Sub Page_Load
If Not Page.IsPostBack then
Dim SQLstring As Object
If MenuSearch = "selected item" Then
SQLString = "SELECT * FROM ProductsTab " & _
"WHERE OuterCategory = '" & MenuSearch & "' " & _
"IF OBJECT_ID(N'ProductsDB..BrandsTab') IS NOT NULL " &
"DROP TABLE BrandsTab " & _
"SELECT Brand, COUNT(*) AS BrandCount INTO BrandsTab FROM ProductsTab " & _
"WHERE OuterCategory = '" & MenuSearch & "' " & _
"GROUP BY Brand "
……………
SqlDataSource2.SelectCommand = SQLString
End If
End Sub
Note: Data from ProductsTab is displayed in Gridview, data from BrandsTab is displayed in Repeater. The subset of selection from ProductsTab is saved in BrandsTab.
The Repeater code is:-
<asp:Repeater runat="server" id="Repeater1" DataSourceID="SqlDataSourceBrand" OnItemCreated="Repeater1_ItemCreated" >
<ItemTemplate>
<asp:Label Text='<%# Eval("Brand") %>' runat="server"/>
<br />
<asp:Label Text='<%# Eval("BrandCount") %>' runat="server"/>
</ItemTemplate>
</asp:Repeater>
I hope the above code helps to explain my problem. I would greatly appreciate any help.


 
Hi and welcome to Tek-Tips. Start by reading faq222-2244, then post this question in forum855

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top