Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 7th, 2008, 04:29 PM
Posts: n/a
Default Problem with CrossPage Postback to Display Data fr

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: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 />

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
        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()
        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.

Similar Threads
Thread Thread Starter Forum Replies Last Post
XML Data Island Display Problem marcuslim XML 8 December 7th, 2004 04:00 AM
Can Main and SubReport get data fr different table yblee Crystal Reports 0 August 19th, 2004 03:37 AM
problem with display of data of xml in excel2002 madhavigun XML 0 August 5th, 2004 10:52 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.