Sub Page_Load(sender As Object, e As EventArgs)
' Verify that the current user has access to access this page
If PortalSecurity.IsInRoles("Admins") = False Then
Response.Redirect("~/Admin/EditAccessDenied.aspx")
End If
If Not (Request.Params("tabid") Is Nothing) Then
tabId = Int32.Parse(Request.Params("tabid"))
End If
If Not (Request.Params("tabindex") Is Nothing) Then
tabIndex = Int32.Parse(Request.Params("tabindex"))
End If
End Sub
--- In [email protected], Dean Fiala
<[EMAIL PROTECTED]> wrote:
> Where's your page_load event handler code?
>
> On 9/15/05, sas0riza <[EMAIL PROTECTED]> wrote:
> >
> > Here's my code:
> >
> > Function GetCardholderByLastandFirst(ByVal lastName As String,
ByVal
> > firstName As String) As System.Data.DataSet
> > Dim connectionString As String = _
> > Dim dbConnection As System.Data.IDbConnection = New
> > System.Data.SqlClient.SqlConnection(connectionString)
> >
> > Dim queryString As String = "SELECT [CardVerification].
> > [CardVerificationUID], [CardVerification].[LastName], ["& _
> > "CardVerification].[FirstName], [CardVerification].
> > [MiddleInitial], [CardVerifica"& _
> > "tion].[Email] FROM [CardVerification] WHERE [CardVerification].
> > [LastName] LIKE ('%' + @LastName + '%') AND [CardVerification].
> > [FirstName] LIKE ('%' + @FirstName + '%')"
> > Dim dbCommand As System.Data.IDbCommand = New
> > System.Data.SqlClient.SqlCommand
> > dbCommand.CommandText = queryString
> > dbCommand.Connection = dbConnection
> >
> > Dim dbParam_lastName As System.Data.IDataParameter = New
> > System.Data.SqlClient.SqlParameter
> > dbParam_lastName.ParameterName = "@LastName"
> > dbParam_lastName.Value = lastName
> > dbParam_lastName.DbType = System.Data.DbType.String
> > dbCommand.Parameters.Add(dbParam_lastName)
> > Dim dbParam_firstName As System.Data.IDataParameter =
> > New System.Data.SqlClient.SqlParameter
> > dbParam_firstName.ParameterName = "@FirstName"
> > dbParam_firstName.Value = firstName
> > dbParam_firstName.DbType = System.Data.DbType.String
> > dbCommand.Parameters.Add(dbParam_firstName)
> >
> > Dim dataAdapter As System.Data.IDbDataAdapter = New
> > System.Data.SqlClient.SqlDataAdapter
> > dataAdapter.SelectCommand = dbCommand
> > Dim dataSet As System.Data.DataSet = New
> > System.Data.DataSet
> > dataAdapter.Fill(dataSet)
> >
> > Return dataSet
> > End Function
> >
> >
> >
> >
> > Function GetCardholderByLast(ByVal lastName As String) As
> > System.Data.DataSet
> > Dim connectionString As String = _
> > Dim dbConnection As System.Data.IDbConnection = New
> > System.Data.SqlClient.SqlConnection(connectionString)
> >
> > Dim queryString As String = "SELECT [CardVerification].
> > [CardVerificationUID], [CardVerification].[LastName], ["& _
> > "CardVerification].[FirstName], [CardVerification].
> > [MiddleInitial], [CardVerifica"& _
> > "tion].[Email] FROM [CardVerification] WHERE [CardVerification].
> > [LastName] LIKE ('%' + @LastName + '%')"
> > Dim dbCommand As System.Data.IDbCommand = New
> > System.Data.SqlClient.SqlCommand
> > dbCommand.CommandText = queryString
> > dbCommand.Connection = dbConnection
> >
> > Dim dbParam_lastName As System.Data.IDataParameter = New
> > System.Data.SqlClient.SqlParameter
> > dbParam_lastName.ParameterName = "@LastName"
> > dbParam_lastName.Value = lastName
> > dbParam_lastName.DbType = System.Data.DbType.String
> > dbCommand.Parameters.Add(dbParam_lastName)
> >
> > Dim dataAdapter As System.Data.IDbDataAdapter = New
> > System.Data.SqlClient.SqlDataAdapter
> > dataAdapter.SelectCommand = dbCommand
> > Dim dataSet As System.Data.DataSet = New
> > System.Data.DataSet
> > dataAdapter.Fill(dataSet)
> >
> > Return dataSet
> > End Function
> >
> >
> >
> >
> > Function GetCardholderByFirst(ByVal firstName As String) As
> > System.Data.DataSet
> > Dim connectionString As String = _
> > Dim dbConnection As System.Data.IDbConnection = New
> > System.Data.SqlClient.SqlConnection(connectionString)
> >
> > Dim queryString As String = "SELECT [CardVerification].
> > [CardVerificationUID], [CardVerification].[LastName], ["& _
> > "CardVerification].[FirstName], [CardVerification].
> > [MiddleInitial], [CardVerifica"& _
> > "tion].[Email] FROM [CardVerification] WHERE ([CardVerification].
> > [FirstName] = @F"& _
> > "irstName)"
> > Dim dbCommand As System.Data.IDbCommand = New
> > System.Data.SqlClient.SqlCommand
> > dbCommand.CommandText = queryString
> > dbCommand.Connection = dbConnection
> >
> > Dim dbParam_firstName As System.Data.IDataParameter =
> > New System.Data.SqlClient.SqlParameter
> > dbParam_firstName.ParameterName = "@FirstName"
> > dbParam_firstName.Value = firstName
> > dbParam_firstName.DbType = System.Data.DbType.String
> > dbCommand.Parameters.Add(dbParam_firstName)
> >
> > Dim dataAdapter As System.Data.IDbDataAdapter = New
> > System.Data.SqlClient.SqlDataAdapter
> > dataAdapter.SelectCommand = dbCommand
> > Dim dataSet As System.Data.DataSet = New
> > System.Data.DataSet
> > dataAdapter.Fill(dataSet)
> >
> > Return dataSet
> > End Function
> >
> >
> >
> >
> >
> >
> >
> > Sub search_Click(sender As Object, e As EventArgs)
> >
> >
> > dgCardholderInfo.DataSource = GetCardholderByLastandFirst
> > (lname.text, fname.text)
> > dgCardholderInfo.DataBind()
> > Label1.Text = "Click on the person's last name that you want to
> > edit:"
> > Label1.Visible = True
> >
> >
> > End Sub
> >
> >
> >
> > Sub search2_Click(sender As Object, e As EventArgs)
> >
> > If lname2.text = ""
> > dgCardholderInfo.DataSource = GetCardholderByFirst(fname2.text)
> > dgCardholderInfo.DataBind()
> >
> > else if fname2.text = ""
> > dgCardholderInfo.DataSource = GetCardholderByLast(lname2.text)
> > dgCardholderInfo.DataBind()
> >
> >
> > End If
> >
> > End Sub
> >
> >
> >
> >
> >
> > Sub dgCardholderInfo_Page(sender as Object, e as
> > DataGridPageChangedEventArgs)
> > 'Assign the CurrentPageIdex property to the new page index value
> >
> > dgCardholderInfo.CurrentPageIndex = e.NewPageIndex
> >
> > 'Rebind the data to the Datagrid
> > dgCardholderInfo.DataSource = GetCardholderByLastandFirst
> > (lname.text, fname.text)
> > dgCardholderInfo.DataBind()
> >
> > End Sub
> >
> >
> >
> >
> > <p align="right">
> > <a href="Cardholders.aspx">Restart</a>
> > </p>
> > <p>
> > Last Name:
> > <asp:TextBox id="lname" runat="server"
> > cssclass="NormalTextBox"></asp:TextBox>
> > <b>-AND-</b> First Name:
> > <asp:TextBox id="fname" runat="server"
> > cssclass="NormalTextBox"></asp:TextBox>
> > <asp:Button id="search"
> > onclick="search_Click" runat="server" cssclass="CommandButton"
> > Text="Search"></asp:Button>
> > <input class="CommandButton"
> > type="reset" value="Clear" />
> > </p>
> > <p>
> > Last Name:
> > <asp:TextBox id="lname2" runat="server"
> > cssclass="NormalTextBox" EnableViewState="False"></asp:TextBox>
> > <b>-OR-</b> First Name:
> > <asp:TextBox id="fname2" runat="server"
> > cssclass="NormalTextBox"></asp:TextBox>
> > <asp:Button id="search2"
> > onclick="search2_Click" runat="server" cssclass="CommandButton"
> > Text="Search"></asp:Button>
> > <input class="CommandButton"
> > type="reset" value="Clear" />
> > </p>
> > <p>
> > <asp:Label id="Label1" runat="server"
> > cssclass="Normal" visible="False"></asp:Label>
> > <br />
> > <asp:DataGrid id="dgCardholderInfo"
> > runat="server" cssclass="Normal" AutoGenerateColumns="False"
> > AllowPaging="True" OnPageIndexChanged="dgCardholderInfo_Page">
> > <HeaderStyle font-
> > bold="True"></HeaderStyle>
> > <PagerStyle
> > mode="NumericPages"></PagerStyle>
> > <Columns>
> > <asp:HyperLinkColumn
> > DataNavigateUrlField="CardVerificationUID"
> > DataNavigateUrlFormatString="Cardholders2.aspx?
CardVerificationUID=
> > {0}" DataTextField="LastName" SortExpression="LastName"
> > HeaderText="LastName"></asp:HyperLinkColumn>
> > <asp:BoundColumn
> > DataField="FirstName" HeaderText="FirstName"></asp:BoundColumn>
> > <asp:BoundColumn
> > DataField="MiddleInitial" HeaderText="MI"></asp:BoundColumn>
> > <asp:BoundColumn
> > DataField="Email" HeaderText="Email"></asp:BoundColumn>
> > </Columns>
> > </asp:DataGrid>
> > </p>
> >
> >
> > Thanks...
> >
> >
> > --- In [email protected], Dean Fiala
> > <[EMAIL PROTECTED]> wrote:
> > > Let's see the code.
> > >
> > > On 9/15/05, sas0riza <[EMAIL PROTECTED]> wrote:
> > > >
> > > > Hello,
> > > >
> > > > I have a couple of search fields, where you can search by
both
> > first
> > > > and last name, or last or first name. I have 2 buttons,
search
> > and
> > > > clear. When you hit search, the record(s) is returned in a
> > datagrid.
> > > >
> > > > However, I am having a problem when you refresh the page,
even
> > > > entering in something different in the search field, once I
hit
> > > > search, the same results get returned in the datagrid and
what I
> > > > entered in the search before reappears in search textbox.
How do
> > I
> > > > prevent this?
> > > >
> > > > In addition, my datagrid is paging enabled and when I go to
the
> > next
> > > > page, I get different records than what I want to show. e.g.
I
> > > > search by last name 'lee' so the datagrid returns all the
records
> > > > with 'lee' but when I go to the next page, the records are
mixed
> > up.
> > > > I'm not sure why?
> > > >
> > > > Any help is greatly appreciated.
> > > >
> > > > Thanks.
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Yahoo! Groups Links
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> > > --
> > > Dean Fiala
> > > Very Practical Software, Inc
> > > http://www.vpsw.com
> > >
> > >
> > > [Non-text portions of this message have been removed]
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
>
>
> --
> Dean Fiala
> Very Practical Software, Inc
> http://www.vpsw.com
>
>
> [Non-text portions of this message have been removed]
------------------------ 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/