Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Displaying Search Results in Other page

Posted on 2014-03-24
4
Medium Priority
?
449 Views
Last Modified: 2014-04-08
I have a ASP.Net Page which includes a DropDown and the Selected item is displayed in a label:

Private Shared Sub DisplaySelection(dropdownlist As Telerik.Web.UI.RadDropDownList, label As Label)

        If dropdownlist.SelectedText <> [String].Empty Then

            label.Text = dropdownlist.SelectedText

        Else

            label.Text = "RadDropDownList is empty"

        End If

    End Sub

    Protected Sub RadDropDownList2_SelectedIndexChanged(sender As Object, e As DropDownListEventArgs) Handles RadDropDownList2.SelectedIndexChanged
        DisplaySelection(RadDropDownList2, Label2)
    End Sub
*************************************************************
I need to show the resulting record in a seperate page.  The query I have in the Submit button is as follows:
 Response.Redirect("SearchByCity.aspx?City=" & Convert.ToString(Me.Label2.Text))
***********************************************************************

This is way wrong and im not sure how is should be.  

The result page "SearchByCity.aspx" contains the following SQL DataSource:

 <asp:SqlDataSource ID="SqlDataSource3" runat="server"
            ConnectionString="<%$ ConnectionStrings:dbMyCMSConnectionString %>"
           SelectCommand="SELECT
      UserProfiles.UserId
    , UserProfiles.City
    , Locations.city
    , Locations.UserId
    , Locations.id
FROM UserProfiles
      INNER JOIN Locations
            ON Locations.UserID = UserProfiles.UserID
                  AND (Locations.City = @City
                  OR UserProfiles.City = @City)">
           <SelectParameters>
               
               <asp:Parameter Name="City" />
               
           </SelectParameters>
                      </asp:SqlDataSource>
0
Comment
Question by:misnstt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 18

Expert Comment

by:Jerry Miller
ID: 39951660
I normally do that sort of thing in a ViewState variable. The main issue is that you don't want to store a large variable like a big array and don't store any sensitive information. Large arrays take up a lot of memory and the ViewState can be decoded.

Overview:
http://msdn.microsoft.com/en-us/library/ms227551(v=vs.85).aspx

Look at disadvantages:
http://msdn.microsoft.com/en-us/library/z1hkazw7(v=vs.85).aspx
0
 

Author Comment

by:misnstt
ID: 39952171
Hello thanks for this information however I need first to know how to query the SQL datasource on ny  SearchByCity.aspx page.  My current query on the submit button is :

Response.Redirect("SearchByCity.aspx?City=" & Convert.ToString(Me.Label2.Text))

And this is not correct.  Im not sure what needs to be changed to make it work.  

Thanks
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39954433
What do you mean by it being not correct?
0
 
LVL 26

Accepted Solution

by:
Alan Warren earned 2000 total points
ID: 39960489
Hi misnstt,

You could set some session variables on RadDropDownList2_SelectedIndexChanged
Session("MySessionParam")=RadDropDownList2.SelectedItem.ToString
' Redirect to results page...

Open in new window

Then modify the SqlDataSource SelectParameters on the results page to consume the Session variables you set on the previous page by declaring them as SessionParameters
      <asp:SqlDataSource ID="SqlDataSource1" runat="server" >
        <SelectParameters>
          <asp:SessionParameter Name="MySqlParamName" Type="String" SessionField="MySessionParam" Size="50" DefaultValue="" />
        </SelectParameters>
      </asp:SqlDataSource>

Open in new window

You should probably clear the session variables using the SQLDataSource_Selected Event
  Protected Sub SqlDataSource1_Selected(sender As Object, e As SqlDataSourceStatusEventArgs)
    '' clear the session params
    Session("MySessionParam") = ""
  End Sub

Open in new window

Also it's a good plan to make sure the session variables exist for each page prior to attempting to reference them
  Protected Sub Page_Init(sender As Object, e As EventArgs) Handles Me.Init
    If Session("MySessionParam") Is Nothing Then
      Session("MySessionParam") = ""
    End If

  End Sub

Open in new window

Respectfully yours,
Alan
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question