Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
On my search.aspx I'm using a Grid View to display search results:
ASP.NET
    <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="False" Width="735px">

        <Columns>
            <asp:BoundField DataField="title" HeaderText="title" SortExpression="title"></asp:BoundField>
            <asp:BoundField DataField="fcontents" HeaderText="fcontents" SortExpression="fcontents"></asp:BoundField>
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:minusConnectionString %>" SelectCommand="SELECT [title], [fcontents] FROM [tpost] WHERE ([fcontents] LIKE '%' + @fcontents + '%')">
        <SelectParameters>
            <asp:ControlParameter ControlID="TextBox1" Name="fcontents" PropertyName="Text" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:Button ID="Button1" runat="server" Text="Button" />
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>

and it works fine and the search results are displayed in the search.aspx page(I use grid view wizard for search results)
And in Master Page i use this code;
HTML
<div style="margin-removed 5px; float: left">
    <form name="searchform" method="get" class="searchform">
        <input type="hidden" name="do" value="search" />
        <input type="hidden" name="subaction" value="search" />
        <input name="story" id="story" type="text" />
        <button type="submit">search</button>
    </form>

Now, I want when a user search in the Master Page, the search results are opened on the new search.aspx page.how can I do this work?thanks
Posted
Updated 25-May-14 11:58am
v4
Comments
Nelek 25-May-14 17:26pm    
Perfect, go ahead and have fun coding.

Since you didn't ask any question, it is difficult to give you a better answer.

I strongly recommend you to read:
How to ask a question[^] and What have you tried?[^]
Sajad Taheri 25-May-14 18:00pm    
thanks.I improved my question...

i) Put the search criteria if short into query string or else add them to session variable.
ii) Now redirect to the particular page i.e. search.aspx here.
iii) Now on load of the search page get the search criteria values from query string or the session variable and do the search operation to populate the grid in the same page with the search results.

Hope his will be of help.
 
Share this answer
 
Comments
Nirav Prabtani 26-May-14 1:45am    
my 5+
Sajad Taheri 26-May-14 2:48am    
thanks my friend,please give me code of your 3steps(prefer by query string)
SRS(The Coder) 26-May-14 5:09am    
Hi Sajad you can see the new cod example added with my response below.
i) Put the search criteria if short into query string or else add them to session variable.
ii) Now redirect to the particular page i.e. search.aspx here.

Ex :-
C#
Response.Redirect("~/SearchResult.aspx?name=smruti");


iii) Now on load of the search page get the search criteria values from query string or the session variable and do the search operation to populate the grid in the same page with the search results.

Ex :-
C#
protected void Page_Load(object sender, EventArgs e)
        {
            string name = string.Empty;
            if(Request.QueryString["name"] != null)
            {
                name = Request.QueryString["name"].ToString();
            }

            // Do the search operation by using the value for name what we got from query            string.
            // then bind the grid with the result data you got from database
        }



Hope his will be of help.
 
Share this answer
 
v2
Comments
Sajad Taheri 26-May-14 6:17am    
i don't have code behind in master page(i use html tags). where i insert this code:

Response.Redirect("~/SearchResult.aspx?name=smruti");

how i can Put the search criteria into query string?

how i can bind the grid view with the result data?

this is my grid view in search.aspx page:

http://8pic.ir/images/24063714045552871721.jpg

I apologize smruti,im so beginner...TNX
SRS(The Coder) 26-May-14 8:48am    
r u using javascript/jquery for all database operations ?
Sajad Taheri 26-May-14 11:01am    
No i use java/jquery only in gallery slide show(light box)and change background text box...
Sajad Taheri 26-May-14 13:22pm    
smruti,I get value of textbox using js in Master page by this code:
<head>
<script type="text/javascript">
function basicPopup() {
var text = document.getElementById('text1').value;
var url = "search.aspx?search=" +text;
popupWindow = window.open(url, 'popUpWindow');
}
</script>
</head>

<body>
<div style="margin-removed 5px; float: left">
<form name="searchform" method="get" class="searchform">
<input type="hidden" name="do" value="search" />
<input type="hidden" name="subaction" value="search" />
<input name="story" id="story" type="text" />
<button type="submit" önclick="basicPopup()">search</button>
</form>
</body>
now when for example search "smruti" in search box in master page,my browser redirect to this address in search.aspx page:
http://localhost:2391/search.aspx?search=smruti
i get get the value of text using javascript...now how bind grid view and text(top url)?!
(As I said before search.aspx page works fine separate)
sajad379 27-May-14 3:13am    
my problem solved!
thanks

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