cyberstore05
Programmer
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.
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.