Hi guys I am trying to create a code that allows me to take either first name or last name or both and display accordingly on the gridview.. Much help is appreciated

viewrecords.aspx

<asp:AccessDataSource ID="AccessDataSource1" runat="server" 
        DataFile="~/App_Data/JABILMCALLEN.mdb" 
                
        
        SelectCommand="SELECT Employees.Name, TrainingDocuments.ReferenceDocument, TrainingDocuments.Description, Certifications.[Started Training], Certifications.[Ended Training], Certifications.TrainedBy, Certifications.Approved
FROM TrainingDocuments INNER JOIN (Employees INNER JOIN Certifications ON Employees.EmployeeID = Certifications.EmployeeID) ON TrainingDocuments.TrainingDocID = Certifications.TrainingDocID
WHERE (((Certifications.Approved)=Yes) AND ((Certifications.TrainingDocID)=[TrainingDocuments].[TrainingDocID]) AND ((Employees.Name)=@nameVar));">

<SelectParameters>
            <asp:QueryStringParameter Name="Name" QueryStringField="Name" Type="String" />
                   </SelectParameters>


    </asp:AccessDataSource>

code behind

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim nameVar As String = Request.QueryString("Name")

        If nameVar = "" Then
            Response.Redirect("Main.aspx") 'Handle empty submissions

        End If


    End Sub

You should write,

string str="viewrecords.aspx?Name=" + textbox1.Text;
Response.Redirect(str);

Is this on the Search.aspx.vb code?

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        Response.Redirect("ViewRecords.aspx?Name=" + Server.UrlEncode(txtName.Text))


      string str="viewrecords.aspx?Name=" + textbox1.Text;

      Response.Redirect(str);

    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.