I have a master/Detail page website, where users can select a category of items from a menu. The selected items (from interrogating a SQL database) are displayed in a GridView (on what I called ResultsPage). Using a Repeater control, I also display the brand names (from the selected items), as well as the total number of items for each brand. LinkButton is used to display the brands in a bulleted format. This works fine.
Next, I want to enable users to click on the LinkButton which will cause a postback and be directed to another page (which I called a SubsetPage), where the selected brands are displayed in another GridView.
The problem is that although a selection of brands is displayed, the total number of brands is incorrect. I guess what happens is the data is lost during postback, or the ViewState is incorrect. I have tried different things without success.
Code from the ResultsPage:
<asp:Repeater runat="server" EnableViewState="true" id="Repeater1" > <ItemTemplate>
<br />
<asp:Label Text='*' Font-Size="7pt" ForeColor="DarkGray" runat="server"/>
<asp:LinkButton ID="LinkButton1" runat="server" Text='<%# Eval("Brand") %>'
PostBackUrl ='<%#"SubsetPage.aspx?BrandSearch=" & Eval("Brand") %>'>
</asp:LinkButton>
<asp:Label Text='(' Font-Size="8pt" ForeColor="DarkGray" runat="server"/>
<asp:Label Text='<%# Databinder.Eval(Container.DataItem, "BrandCount") %>' Font-Size="8pt" ForeColor="Black" runat="server"/>
<asp:Label Text=')' Font-Size="8pt" ForeColor="DarkGray" runat="server"/>
<br />
</ItemTemplate>
</asp:Repeater>
VB Code from the SubsetPage:
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If Not Page.IsPostBack Then
Dim ConnectionString As String = "Data Source=CYBERSTORE\SQLEXPRESS;Initial Catalog=ProductsDB;Integrated Security=True"
Using SqlCon1 As New SqlConnection(ConnectionString)
If SqlCon1.State <> ConnectionState.Open Then
SqlCon1.Open()
End If
Dim BrandSearch As String = Request.QueryString("BrandSearch")
Using SqlCom1 As New SqlCommand("ProdProcMSearch", SqlCon1)
SqlCom1.CommandType = CommandType.StoredProcedure
SqlCom1.Parameters.Add("@Brand", Data.SqlDbType.varchar, 50)
GrdMenuSub.DataSource = SqlCom1.ExecuteReader()
GrdMenuSub.DataBind()
SqlCon1.Close()
End Using
End Using
End If
End Sub
I will appreciate any suggestion, along with some example code if possible. Please let me know if you require additional information.