Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7597189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:05:58+00:00 2026-05-30T22:05:58+00:00

I got a quick question, I am building an ASP.NET website and have a

  • 0

I got a quick question, I am building an ASP.NET website and have a database set up (SQL Server 2008). One one of my pages I am displaying all of all of the entries of the database with a search text box at the top. How would I go about taking the value that the user entered and using that string to display only the data entries that apply to it.

Here is my code for the .aspx file

<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Layout.Master" CodeBehind="db.aspx.vb" Inherits="Project4.db" %>

    <fieldset>
        <legend>Search</legend>
        Last Name: <asp:TextBox ID="LastNameSearch" runat="server"></asp:TextBox>
        <asp:Button ID="Submit" runat="server" Text="Search" /> <br />
    </fieldset>



<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" 
    AutoGenerateColumns="False" BackColor="White" BorderColor="#3366CC" 
    BorderStyle="None" BorderWidth="1px" CellPadding="4" 
    DataKeyNames="FirstName,LastName,PhoneNum" AllowPaging="True">
    <Columns>
        <asp:CommandField ShowEditButton="True" />
        <asp:BoundField DataField="FirstName" HeaderText="FirstName" 
            SortExpression="FirstName" ReadOnly="True" />
        <asp:BoundField DataField="LastName" HeaderText="LastName"
            SortExpression="LastName" ReadOnly="True" />
        <asp:BoundField DataField="PhoneNum" HeaderText="PhoneNum"
            SortExpression="PhoneNum" ReadOnly="True" />
        <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
        <asp:CommandField ShowDeleteButton="True" />
    </Columns>
    <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
    <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
    <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
    <RowStyle BackColor="White" ForeColor="#003399" />
    <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
    <SortedAscendingCellStyle BackColor="#EDF6F6" />
    <SortedAscendingHeaderStyle BackColor="#0D4AC4" />
    <SortedDescendingCellStyle BackColor="#D6DFDF" />
    <SortedDescendingHeaderStyle BackColor="#002876" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    ConnectionString="<%$ ConnectionStrings:Database1ConnectionString %>" 
    SelectCommand="SELECT [FirstName], [LastName], [PhoneNum], [Email] FROM [MailList]" 
    ViewStateMode="Disabled" OldValuesParameterFormatString="original_{0}">

</asp:SqlDataSource>

Now I want to search the string and compare it to the second column of the database the LastName and only display the records where the last name matches that. Any help would be greatly appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T22:05:59+00:00Added an answer on May 30, 2026 at 10:05 pm

    This should be pretty close, doing it from memory though so it may be off a little. It should be enough to get you going in the right direction though I think

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:Database1ConnectionString %>" 
        SelectCommand="SELECT [FirstName], [LastName], [PhoneNum], [Email] FROM [MailList] WHERE [LastName] = @lastName" 
        ViewStateMode="Disabled" OldValuesParameterFormatString="original_{0}">
        <SelectParameters>
            <asp:ControlParameter ControlID="LastNameSearch" Name="lastName" defaultValue="" />
        </SelectParameters>
    </asp:SqlDataSource>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got one quick question. Is there any simple way to detect if .net
A quick question. I've got two textboxes running server side and have their visibility
I've got a quick question about default values in PL/SQL functions in Oracle. Take
just a quick question. I've got this table in a Word template which have
I've just got a quick question that if you have time would be great
I have a quick question i hope you guys can answer, i've got a
I have one question. I made quick search on the site, but don't found
I have a (hopefully) quick question. I've got some stepper boxes. Though really this
I have a quick question. Say, I've got a string this string has some
Alright, I've got a quick question. I'm currently working with a legacy database, so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.