I'm trying to create simple search. I have "txtSearch" textBox and "search" button in MasterPage, button has PostbackUrl= Search.aspx

In MasterPage

<asp:TextBox ID="txtSearch" runat="server" ValidationGroup="b" Text="Users Search" ForeColor="Silver">Users Search</asp:TextBox>

<asp:Button ID="btnSearch" runat="server" Text="Search" ValidationGroup="b" 
PostBackUrl="~/Search.aspx" onclick="btnSearch_Click" />

In Search.aspx i have GridView that shows me results and SqlDataSource

<asp:SqlDataSource ID="SqlDataSearchResult" runat="server" 
    ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 

    SelectCommand="SELECT vw_aspnet_Users.UserId, vw_aspnet_Users.UserName, Custon_UserInfo.UserId AS Expr1, Custon_UserInfo.FirstName, Custon_UserInfo.LastName, Custon_UserInfo.Location, Custon_UserInfo.Avatar, Custon_MoneyWork.UserId AS Expr2, Custon_MoneyWork.Money, vw_aspnet_Users.LastActivityDate FROM vw_aspnet_Users INNER JOIN Custon_UserInfo ON vw_aspnet_Users.UserId = Custon_UserInfo.UserId INNER JOIN Custon_MoneyWork ON vw_aspnet_Users.UserId = Custon_MoneyWork.UserId WHERE (vw_aspnet_Users.UserName LIKE '%' + @UserName + '%')">
    <SelectParameters>
        <asp:FormParameter FormField="txtSearch" Name="UserName" Type="String" />
    </SelectParameters>
</asp:SqlDataSource>

In Define Parameters : UserName =Request.Form("txtSearch") as it needs to be, but it's not working. I tried with session["search"]=txtSearch.text; and its working.. But not with Request.Form..

UPD I tryed to use QueryStringField instead of FormField and it works, don't know whats wrong with FormField.

link|improve this question

58% accept rate
You should add a more meaningful question title. This has more to do with SqlDataSource than Request.Form. – Chris Pietschmann Sep 4 '11 at 23:03
<asp:FormParameter FormField="txtSearch" Name="UserName" Type="String" /> === Request.Form("txtSearch") – RaShe Sep 4 '11 at 23:06
Have you confirmed that the search text is present in Request.Form("txtSearch")? – John Saunders Sep 4 '11 at 23:06
Hm.. It's not. Why can it be? – RaShe Sep 4 '11 at 23:24
Is the page called via a GET instead of a POST? – John Saunders Sep 5 '11 at 0:55
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown

Browse other questions tagged or ask your own question.