try this to implement the below method inside of ur search click event...here i have given the sample search with different fields one is ddl and textbox, keep ur textbox id's and try..
public void SearchStudentInfo()
{
try
{
lblError.Text = string.Empty;
if (txtSearch.Text.Trim() != string.Empty || ddlUserType.SelectedIndex != 0 || ddlStatus.SelectedValue != "-1")
{
ViewState["SearchText"] = txtSearch.Text.Trim();
studentCollection = SerachData((MyGenericCollection<StudentBO>)ViewState["StudentCollection"], Convert.ToString(ViewState["SearchText"]));
if (studentCollection.Count > 0)
{
ViewState["SearchCollection"] = studentCollection;
ViewState["SearchText"] = txtSearch.Text.Trim();
BindGridView(studentCollection, true);
}
else
{
BindGridView(null, true);
}
}
else
{
BindGridView((MyGenericCollection<StudentBO>)ViewState["StudentCollection"], false);
}
}
catch (Exception ex)
{
ExpLogBL.CreateExceptionLog(ex, "Sohan", "Officer/UserInfo.aspx");
Response.Redirect("../Common/Errorpage.aspx");
}
}
--
private MyGenericCollection<StudentBO> SerachData(MyGenericCollection<StudentBO> studentCollection, string NameOrId)
{
try
{
string strName = string.Empty;
MyGenericCollection<StudentBO> searchCollection = new MyGenericCollection<StudentBO>();
foreach (StudentBO objStudentBO in studentCollection)
{
bool bUserType = true;
bool bUserStatus = true;
strName = objStudentBO.FirstName + " " + objStudentBO.LastName;
if (ddlUserType.SelectedIndex != 0)
{
if (objStudentBO.UserType != (Constants.UserType)Convert.ToByte(ddlUserType.SelectedValue)) { bUserType = false; }
}
if (ddlStatus.SelectedIndex != 0)
{
byte Status = Convert.ToByte(ddlStatus.SelectedValue);
if (Status >= 0 && (objStudentBO.Status != Convert.ToBoolean(Status))) { bUserStatus = false; }
}
if (bUserStatus == true && bUserType == true && strName.IndexOf(NameOrId, 0, StringComparison.CurrentCultureIgnoreCase) >= 0)
{
searchCollection.Add(objStudentBO);
}
}
return searchCollection;
}
catch (Exception ex)
{
throw ex;
}
}