Click here to Skip to main content
16,014,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends,
I am working on a search page, i have used one text box and one button .Now on the basis of text entered,on button click event.I want to show the result on an another asp.net page , in a grid view control.How can i do it.

Thanks in advance friends.
Posted
Updated 9-Jun-11 20:06pm
v3

Try this,

In your page1.aspx,
XML
<body>
    <form id="form1" runat="server">
      <asp:TextBox ID="txt" runat="server"></asp:TextBox>
      <asp:Button ID="btn" runat="server" Text="Search" OnClick="btn_Click"/>
    </form>
</body>




In page1.aspx.cs,
C#
protected void btn_Click(object sender, EventArgs e)
    {

        Response.Redirect("Page2.aspx?a="+txt.Text);
    }



Then in page2.asp.cs,
Using Request.QueryString["a"], you will get the passed value and find the result using that value.


-----------
@Nidhish
 
Share this answer
 
In the code behind (button click handler)

C#
Response.Redirect("http://myotherpage.aspx")
 
Share this answer
 
Save your search result in session. And use this session on other page. For ex
save result in Session("ABC").
Then next page where you want to use create data table.
DataTable dt = new DataTable();
dt = Session("ABC");

Now all result in dt. And easily use DataTable value on this page.
 
Share this answer
 
A simple solution from your perspective would be to use Session.
On the click event of a search button, you will set session values to the values you want, ex.: Session["Search"] = search value;
On the receiving end, you simply read the value via Session["Search"].

How to: Save Values in Session State
How to: Read Values from Session State
ASP.NET Session State Overview
 
Share this answer
 
XML
<form id="form1" runat="server">
    <div>
        <asp:TextBox ID="Textbox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="Search" OnClientClick="go()"/>
    </div>
    <script language="javascript" type="text/javascript">
        function go() {
            if (document.getElementById("Textbox1").value.length > 0) {
                var keyValue = document.getElementById("Textbox1").value;
                location.href = 'Result.aspx?key=' + keyValue;
            }
        }
    </script>
    </form>



Result.aspx.vb

VB
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      Dim key As String = Request.QueryString("key")
  End Sub
 
Share this answer
 
Just Use it in your Code-Behind, it will be redirected to Login page as how you have mentioned in your page.

Response.Redirect("http://Login.aspx")
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900