M.L. Martin
asked on
How do I post form data and get results non-programmatically?
I am trying to post form field data from a page. The form filed is an asp.net textbox control. I am trying to do the following:
1. Enter a value in the form.
2. Click the submit button.
3. Return the results in a Gridview control or even a Detail view.
This is a simple ASP.net webform page. I am doing this in VB.net. I am trying to avoid doing this programmatically in the Code Behind page and I know it can be done but I am missing something. I created the SQLDataSource and when I test it there it brings back results. I can even pass a url string value and get results. I believe I have forgotten how to do this with form field values. Do I need to place something in the code behind? It seems I am missing something simple. Here is my code below:
-------------------------- ---------- -------
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="2posted.aspx.vb" Inherits="_2posted" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="search" runat="server"></asp:TextB ox>
</div>
<asp:Button ID="Button1" runat="server" Text="Button" PostBackUrl="~/2posted.asp x" />
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False " DataSourceID="SqlDataSourc e1">
<Columns>
<asp:BoundField DataField="bodypartmg" HeaderText="bodypartmg" SortExpression="bodypartmg " />
</Columns>
</asp:GridView>
</div>
<div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:fitnesCo nnectionSt ring %>"
SelectCommand="SELECT * FROM [exercises] WHERE ([eid] = @eid)">
<SelectParameters>
<asp:FormParameter FormField="search" Name="eid" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
-------------------------- ----------
Partial Class _2posted
Inherits System.Web.UI.Page
'End Sub
End Class
1. Enter a value in the form.
2. Click the submit button.
3. Return the results in a Gridview control or even a Detail view.
This is a simple ASP.net webform page. I am doing this in VB.net. I am trying to avoid doing this programmatically in the Code Behind page and I know it can be done but I am missing something. I created the SQLDataSource and when I test it there it brings back results. I can even pass a url string value and get results. I believe I have forgotten how to do this with form field values. Do I need to place something in the code behind? It seems I am missing something simple. Here is my code below:
--------------------------
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="2posted.aspx.vb"
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="search" runat="server"></asp:TextB
</div>
<asp:Button ID="Button1" runat="server" Text="Button" PostBackUrl="~/2posted.asp
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False
<Columns>
<asp:BoundField DataField="bodypartmg" HeaderText="bodypartmg" SortExpression="bodypartmg
</Columns>
</asp:GridView>
</div>
<div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:fitnesCo
SelectCommand="SELECT * FROM [exercises] WHERE ([eid] = @eid)">
<SelectParameters>
<asp:FormParameter FormField="search" Name="eid" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
--------------------------
Partial Class _2posted
Inherits System.Web.UI.Page
'End Sub
End Class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER