Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to reload page when user enters info in textbox?
Message
From
29/04/2008 13:06:09
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
How to reload page when user enters info in textbox?
Miscellaneous
Thread ID:
01313951
Message ID:
01313951
Views:
51
I have stumbled through my first ASP page with two textboxes that will query an Access data table and show matching records.

When it first runs, it shows the data fine (becuase of DefaultValues on the asp:ControlParameter). But when I enter a new search criteria in one of the text boxes, how do I get the form to re-execute and show the matching results?

It can get it to update if I click on one of the Column Headers, but I want to add a button for the user to click re-search, or do it when they hit enter.

Here is the code (don't laugh, this is a total newbie effort. I don't have a clue what I am doing, but I know I'm kinda close):
< %@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="DwgDatabase._Default" % >

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>ACAD Drawing Database Search</title>
    <style type="text/css">
        </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
         <table>
            <tr>
                <td>
                    Search Phrase
                </td>
                <td>
                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                </td>
                <td>
                    Drawn By
                </td>
                <td>
                    <asp:TextBox ID="txtDrawnBy" runat="server"></asp:TextBox>
                </td>
            </tr>
         </table>
    
    </div>

    <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="\\fs4\acad\database\dwg.mdb"
        SelectCommand="SELECT dwg_no, desc_1, desc_2, dwg_date, dwn_by, rev, scale, job_num, filename, notes FROM Dwg WHERE (dwn_by LIKE '%' + @DrawnBy + '%') AND (desc_1 LIKE '%' + @SearchText + '%') OR (dwn_by LIKE '%' + @DrawnBy + '%') AND (desc_2 LIKE '%' + @SearchText + '%') OR (dwn_by LIKE '%' + @DrawnBy + '%') AND (dwg_no LIKE '%' + @SearchText + '%')">
        <SelectParameters>
            <asp:ControlParameter ControlID="txtDrawnBy" Name="DrawnBy" PropertyName="Text" Type="String" DefaultValue="A" />
            <asp:ControlParameter ControlID="TextBox1" Name="SearchText" PropertyName="Text" Type="String" DefaultValue="A" />
        </SelectParameters>
    </asp:AccessDataSource>

    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" PageSize="30" AllowSorting="True" AutoGenerateColumns="False"
        DataSourceID="AccessDataSource1" Font-Names="Swis721 LtCn BT">
        <Columns>
            <asp:BoundField DataField="dwg_no" HeaderText="dwg_no" SortExpression="dwg_no" />
            <asp:BoundField DataField="desc_1" HeaderText="desc_1" SortExpression="desc_1" />
            <asp:BoundField DataField="desc_2" HeaderText="desc_2" SortExpression="desc_2" />
            <asp:BoundField DataField="dwg_date" HeaderText="dwg_date" SortExpression="dwg_date" />
            <asp:BoundField DataField="dwn_by" HeaderText="dwn_by" SortExpression="dwn_by" />
            <asp:BoundField DataField="rev" HeaderText="rev" SortExpression="rev" />
            <asp:BoundField DataField="scale" HeaderText="scale" SortExpression="scale" />
            <asp:BoundField DataField="job_num" HeaderText="job_num" SortExpression="job_num" />
            <asp:BoundField DataField="filename" HeaderText="filename" SortExpression="filename" />
            <asp:BoundField DataField="notes" HeaderText="notes" SortExpression="notes" />
        </Columns>
    </asp:GridView>
    </form>
</body>
</html>
Next
Reply
Map
View

Click here to load this message in the networking platform