Solved

<asp:formparameter> not working

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# GridRow get Old/New Value 1 55
What is Thread.Sleep? 5 45
How to avoid saving tif files a 2nd time using VS2015 and C#? 1 27
Vb.net dynamic formulas in runtime 11 61
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
A short film showing how OnPage and Connectwise integration works.

930 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

9 Experts available now in Live!

Get 1:1 Help Now