Solved

<asp:formparameter> not working

Posted on 2008-10-20
1
527 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
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now