Welcome Guest
Tanvtech logo
Tanvtech logo
In this article we are going to modify last article and make the search by lastname or date of birth

I have added a new textbox for DOB as shown below
Type in the last name or date of birth of the student.

And in the button click event replace the Datainfo with this
var datainfo = db.StudentInfos.ToList().Where(x => x.StudentLastName.Equals(TanvtechLastNameTextBox.Text)
|| x.DOB.Value.ToShortDateString().Equals(TanvtechDOBTextBox.Text)).ToList();
Question4: Search by Last name contain a letter or date of birth
var datainfo = db.StudentInfos.ToList().Where(x => (TanvtechLastNameTextBox.Text.Length== 0
|| x.StudentLastName.ToLower().Contains(TanvtechLastNameTextBox.Text.ToLower()))
&& (TanvtechDOBTextBox.Text.Length == 0 || x.DOB.Value.ToShortDateString().Equals(TanvtechDOBTextBox.Text))).ToList();
Add some style to the page for example i want to add paging to the datagrid

Update the table style like

Update the GridView style and pagingsize allowpaging and the onPageIndexChanging event as show below.
Update the code as show below.

© Tanvtech. All Rights Reserved.