Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search a bound gridview 1

Status
Not open for further replies.

kjohnson530

IS-IT--Management
Mar 26, 2006
28
US
I'm new to .net and I've created a bound gridview. The gridview displays all records upon opening. I'd like to be able to drilldown into the data with a searchbox.

Is there an easy way using aspx.vb to do this.

Please be patient as my coding skills are pretty weak at this point?

beleow is my code
Code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

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

<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    &nbsp;<asp:GridView ID="CustomerList" runat="server" 
            AutoGenerateColumns="False" CssClass="GridView1" DataSourceID="SqlDataSource1" >

</asp:GridView> 


    </div>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ITConnectionString %>" 
        OldValuesParameterFormatString="original_{0}" >
        
    </asp:SqlDataSource>
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:Button ID="Button1" runat="server" Text="Search" />
    </form>


</body>
</html>
 
you wouldn't search the gridview, that's just a UI element so humans can read tabular data. you would query the datasource and bind those results to the grid. i believe there is a way to set parameters on datasource controls and bind the parameter value to the control. Search MSDN for SqlDataSource control and input parameters.

a word of caution.
1. datasource controls are the worst part webforms. you cannot debug them, optimize them, or inject logic into them. they only work in the simplest scenarios of forms over data.
2. if you have any significant amount of data you will need to implement paging. your first thought would probably be the built in paging on the gridview. again, this only works for small amounts of data. to gain any real preformance benefit you will need to page from the database, not the client (asp.net).

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top