Solved

<asp:formparameter> not working

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

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

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…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

689 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