I am using ASP.NET with C# and subsonic. I am trying to setup a search on a text field by first and last name.
First or Last Name: <asp:TextBox ID="txtSearchName" runat="server"></asp:TextBox>
<asp:linkButton runat="server" Text="Send" onclick="btnSubmit_Click" />
<asp:GridView
border="0"
cellpadding="3"
cellspacing="3"
ShowHeader="True"
allowsorting="true"
ID="GridView1"
runat="server"
AutoGenerateColumns="false"
Visible="false"
AllowPaging="True"
PageSize="10"
PagerStyle-Mode="NumericPages"
OnPageIndexChanging="GridView1_PageIndexChanging"
>
In the code behind, I have this:
private void BuildGridView1()
{
GridView1.DataSource = new Select(PastAwardName.Schema.TableName + ".*", PastAwardType.Schema.TableName + ".*")
.From(PastAwardName.Schema)
.InnerJoin(PastAwardType.Schema.TableName, PastAwardType.Columns.VolID, PastAwardName.Schema.TableName, PastAwardName.Columns.VolID)
.Where(PastAwardName.Columns.LName).IsEqualTo(this.txtSearchName.Text)
.Or(PastAwardName.Columns.FName).IsEqualTo(this.txtSearchName.Text)
.OrderAsc(PastAwardType.Columns.AwardYear)
.ExecuteDataSet();
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
BuildGridView1();
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataBind();
}
This works if you enter either the first or last name, but I want to be able to search for them both at the same time from one text field. Is this possible?