What is it though? Don't I need the file in order for the code to work? --- In [email protected], Dean Fiala <[EMAIL PROTECTED]> wrote: > Yes, > <%@ Page Language="vb" AutoEventWireup="false" > Codebehind="SearchDataGrid.aspx.vb" > Inherits="Playground.SearchDataGrid"%> > > On 9/16/05, sas0riza <[EMAIL PROTECTED]> wrote: > > What's the codebehing? SearchDataGrid.aspx.vb? > > > > > > --- In [email protected], Dean Fiala > > <[EMAIL PROTECTED]> wrote: > > > Yes, you will have to code that yourself, but it doesn't cause any > > > change to how the grid pages and searches, only has to how you > > create > > > the first column. > > > > > > On 9/16/05, sas0riza <[EMAIL PROTECTED]> wrote: > > > > Also I forgot to mention that in my datagrid, the first column is > > > > clickable in that when I click on a last name, the record > > > > information is editable on another page on a form. Would this > > case > > > > any changes? > > > > > > > > Thanks. > > > > > > > > --- In [email protected], Dean Fiala > > > > <[EMAIL PROTECTED]> wrote: > > > > > Here's code for a page that fills a datagrid and lets you > > search > > > > for > > > > > either first or last name and lets you page. Html follows... > > > > > > > > > > Imports System.Data.SqlClient > > > > > Public Class SearchDataGrid > > > > > Inherits System.Web.UI.Page > > > > > > > > > > #Region " Web Form Designer Generated Code " > > > > > > > > > > 'This call is required by the Web Form Designer. > > > > > <System.Diagnostics.DebuggerStepThrough()> Private Sub > > > > InitializeComponent() > > > > > > > > > > End Sub > > > > > Protected WithEvents txtFirst As > > > > System.Web.UI.WebControls.TextBox > > > > > Protected WithEvents txtLast As > > > > System.Web.UI.WebControls.TextBox > > > > > Protected WithEvents dg As > > System.Web.UI.WebControls.DataGrid > > > > > Protected WithEvents btn As > > System.Web.UI.WebControls.Button > > > > > > > > > > 'NOTE: The following placeholder declaration is required > > by the > > > > > Web Form Designer. > > > > > 'Do not delete or move it. > > > > > Private designerPlaceholderDeclaration As System.Object > > > > > > > > > > Private Sub Page_Init(ByVal sender As System.Object, ByVal > > e As > > > > > System.EventArgs) Handles MyBase.Init > > > > > 'CODEGEN: This method call is required by the Web Form > > > > Designer > > > > > 'Do not modify it using the code editor. > > > > > InitializeComponent() > > > > > End Sub > > > > > > > > > > #End Region > > > > > > > > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal > > e As > > > > > System.EventArgs) Handles MyBase.Load > > > > > 'Put user code to initialize the page here > > > > > If Not Page.IsPostBack Then > > > > > BindGrid() > > > > > End If > > > > > End Sub > > > > > > > > > > Private Sub btn_Click(ByVal sender As System.Object, ByVal > > e As > > > > > System.EventArgs) Handles btn.Click > > > > > dg.CurrentPageIndex = 0 > > > > > BindGrid() > > > > > End Sub > > > > > > > > > > Private Sub BindGrid() > > > > > dg.DataSource = GetCustomer() > > > > > dg.DataBind() > > > > > End Sub > > > > > > > > > > Private Function GetCustomer() As DataTable > > > > > Dim SQL As String > > > > > Dim WHERE As String = "" > > > > > SQL = "SELECT * FROM Customers" > > > > > If txtFirst.Text.Length > 0 Then > > > > > WHERE = " WHERE FirstName LIKE '%" & txtFirst.Text > > > > & "%'" > > > > > End If > > > > > If txtLast.Text.Length > 0 Then > > > > > If WHERE.Length = 0 Then > > > > > WHERE = " WHERE " > > > > > Else > > > > > WHERE &= " AND " > > > > > End If > > > > > WHERE &= "LastName LIKE '%" & txtLast.Text & "%'" > > > > > End If > > > > > > > > > > Dim conn As SqlConnection = New > > > > > SqlConnection(ConfigurationSettings.AppSettings ("connString")) > > > > > Dim cmd As SqlCommand = New SqlCommand(SQL & WHERE, > > conn) > > > > > Dim da As SqlDataAdapter = New SqlDataAdapter(cmd) > > > > > Dim dt As DataTable = New DataTable > > > > > da.Fill(dt) > > > > > Return dt > > > > > End Function > > > > > > > > > > Private Sub dg_PageIndexChanged(ByVal source As Object, > > ByVal > > > > e As > > > > > System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles > > > > > dg.PageIndexChanged > > > > > dg.CurrentPageIndex = e.NewPageIndex > > > > > BindGrid() > > > > > End Sub > > > > > End Class > > > > > > > > > > <%@ Page Language="vb" AutoEventWireup="false" > > > > > Codebehind="SearchDataGrid.aspx.vb" > > > > > Inherits="Playground.SearchDataGrid"%> > > > > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> > > > > > <HTML> > > > > > <HEAD> > > > > > <title>SearchDataGrid</title> > > > > > > > > > > </HEAD> > > > > > <body> > > > > > <form id="Form1" method="post" runat="server"> > > > > > <table> > > > > > <tr> > > > > > <td><table> > > > > > <tr> > > > > > > > > > <td>First:</td> > > > > > > > > > <td><asp:TextBox ID="txtFirst" > > > > Runat="server"></asp:TextBox></td> > > > > > > > > > <td>Last:</td> > > > > > > > > > <td><asp:TextBox ID="txtLast" > > > > Runat="server"></asp:TextBox></td> > > > > > > > > > <td><asp:Button ID="btn" Text="Search" > > > > Runat="server"></asp:Button></td> > > > > > </tr> > > > > > </table> > > > > > </td> > > > > > </tr> > > > > > <tr> > > > > > <td><asp:DataGrid id="dg" > > > > runat="server" AllowPaging="True" > > > > > AllowSorting="True" AutoGenerateColumns="False" > > > > > > > PageSize="5"> > > > > > <Columns> > > > > > > > > > <asp:BoundColumn DataField="FirstName" > > > > > SortExpression="FirstName" ReadOnly="True" > > > > > HeaderText="First"></asp:BoundColumn> > > > > > > > > > <asp:BoundColumn DataField="LastName" > > > > > SortExpression="LastName" ReadOnly="True" > > > > > HeaderText="Last"></asp:BoundColumn> > > > > > > > > > <asp:BoundColumn DataField="EmailAddress" > > > > > SortExpression="EmailAddress" ReadOnly="True" > > > > > HeaderText="Email"></asp:BoundColumn> > > > > > > > </Columns> > > > > > > > <PagerStyle > > > > Mode="NumericPages"></PagerStyle> > > > > > > > </asp:DataGrid></td> > > > > > </tr> > > > > > </table> > > > > > </form> > > > > > </body> > > > > > </HTML> > > > > > > > > > > > > > > > -- > > > > > Dean Fiala > > > > > Very Practical Software, Inc > > > > > http://www.vpsw.com > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Yahoo! Groups Links > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > Dean Fiala > > > Very Practical Software, Inc > > > http://www.vpsw.com > > > > > > > > > > > > > > Yahoo! Groups Links > > > > > > > > > > > > > > > > > -- > Dean Fiala > Very Practical Software, Inc > http://www.vpsw.com
------------------------ Yahoo! Groups Sponsor --------------------~--> Most low income households are not online. Help bridge the digital divide today! http://us.click.yahoo.com/cd_AJB/QnQLAA/TtwFAA/saFolB/TM --------------------------------------------------------------------~-> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
