1

I am trying to create a c# webform that displays information from a database based on a users input. My goal would be for a user to type a number in the Store Number box and that number be used in the where cause in the select statement.

<%@ Page Language="C#" AutoEventWireup="true"      
CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication4.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
  <body>
    <form id="form1" runat="server">
    <div>

    <br />
    Store #<br />
    <input id="Text1" type="text" /><br />
    <br />
    <br />

</div>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
        <Columns>
            <asp:BoundField DataField="Prop ID" HeaderText="Prop ID" SortExpression="Prop ID" />
            <asp:BoundField DataField="Parcel/Account" HeaderText="Parcel/Account" SortExpression="Parcel/Account" />
            <asp:BoundField DataField="State" HeaderText="State" SortExpression="State" />
            <asp:BoundField DataField="Juris Cd" HeaderText="Juris Cd" SortExpression="Juris Cd" />
            <asp:BoundField DataField="Address 1" HeaderText="Address 1" SortExpression="Address 1" />
            <asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
            <asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
            <asp:BoundField DataField="Zip Code" HeaderText="Zip Code" SortExpression="Zip Code" />
            <asp:BoundField DataField="Owner" HeaderText="Owner" SortExpression="Owner" />
            <asp:BoundField DataField="Open Date" HeaderText="Open Date" SortExpression="Open Date" />
            <asp:BoundField DataField="Close Date" HeaderText="Close Date" SortExpression="Close Date" />
            <asp:BoundField DataField="Lease Begin" HeaderText="Lease Begin" SortExpression="Lease Begin" />
            <asp:BoundField DataField="Lease End" HeaderText="Lease End" SortExpression="Lease End" />
            <asp:BoundField DataField="Year" HeaderText="Year" SortExpression="Year" />
            <asp:BoundField DataField="Prop Type" HeaderText="Prop Type" SortExpression="Prop Type" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"     ConnectionString="<%$ ConnectionStrings:masterConnectionString %>"     SelectCommand="SELECT * FROM [Prop_Info$]"></asp:SqlDataSource>
</form>
</body>
</html>

Thanks in Advance

1
  • Did my solution solve your issue? Commented Aug 18, 2015 at 11:43

1 Answer 1

1

Set up your sqldatasource like this:

<asp:SqlDataSource ID="SqlDataSource1"
    ConnectionString="<%$ ConnectionStrings:MyConn %>"
    SelectCommand="SELECT FirstName FROM Users"
    FilterExpression="FirstName='{0}'"
    runat="server">
 <FilterParameters>
    <asp:ControlParameter Name="FirstName" ControlID="txtFirstName" PropertyName="Text" />
 </FilterParameters> 
</asp:SqlDataSource>

<asp:TextBox runat="server" Id="txtFirstName"></asp:TextBox>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.