Solved

<asp:formparameter> not working

Posted on 2008-10-20
1
542 Views
Last Modified: 2013-11-26
Hello Experts,
i have a textbox and a button in a page called ask.aspx. like below
 <asp:TextBox ID="tbempname" runat="server"></asp:TextBox>
    <asp:Button ID="btnFindEmp" runat="server" Text="Find Emp" PostBackUrl="~/textform.aspx" />
   
and in the textform.aspx page i have gridview showing the employee details
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" AllowPaging="True" AutoGenerateColumns="False" BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" CellPadding="2" DataKeyNames="EmployeeID" ForeColor="Black" GridLines="None">
        <FooterStyle BackColor="Tan" />
        <Columns>
            <asp:BoundField DataField="EmployeeID" HeaderText="Emp Number" HtmlEncode="False"
                InsertVisible="False" ReadOnly="True" SortExpression="EmployeeID" />
            <asp:BoundField DataField="FirstName" HeaderText="First Name" SortExpression="FirstName" />
            <asp:BoundField DataField="LastName" HeaderText="Last Name" SortExpression="LastName" />
            <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
        </Columns>
        <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
        <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
        <HeaderStyle BackColor="Tan" Font-Bold="True" />
        <AlternatingRowStyle BackColor="PaleGoldenrod" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:northwndConnectionString %>"
        SelectCommand="SELECT [EmployeeID], [FirstName], [LastName], [Title] FROM [Employees] WHERE ([LastName] = @LastName)">
        <SelectParameters>
            <asp:FormParameter FormField="tbempname" Name="LastName" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>

so basically when i type a emp lastname in the ask.aspx, its should dispay the results in the girdview in the textform.aspx.
but IT DOES NOT DISPLAY THE GRID AT ALL. just displays a blank page.
any idea or suggestions are highly appreciated.
Thanks
0
Comment
Question by:niceoneishere
[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
1 Comment
 
LVL 26

Accepted Solution

by:
Anurag Thakur earned 500 total points
ID: 22763997
your text box is on one page and the form parameter is on another page and you want to access the textbox text in another page
cannot be done this way
you need to pass the text box value to the second page and then only the value will be assigned to the formparameter

simple sample of same page formparameter
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.formparameter.aspx
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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