CODE BEHIND
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Linq.SqlClient;
public partial class LinqWhereExample : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
gvLikeOperator.DataSource = GetStudentList();
gvLikeOperator.DataBind();
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (txtContactsSearch.Text.Trim() != string.Empty)
{
var data = (from m in GetStudentList()
where m.Number <= Convert.ToInt32(txtContactsSearch.Text.Trim())
select m);
gvLikeOperator.DataSource = data;
gvLikeOperator.DataBind();
}
}
private List<Student> GetStudentList()
{
List<Student> StudentStudents = new List<Student>{
new Student{StudentID=1, StudentName="Amin", Number =55},
new Student{StudentID=2, StudentName="Alomgir" , Number =55},
new Student{StudentID=3, StudentName="Ashikur Rahman", Number =65},
new Student{StudentID=4, StudentName="Shamim Ahmed" , Number =55},
new Student{StudentID=5, StudentName="Amolash" , Number =95},
new Student{StudentID=6, StudentName="Alum" , Number =95},
new Student{StudentID=7, StudentName="Abil", Number =75},
new Student{StudentID=8, StudentName="Enamul", Number =95},
new Student{StudentID=9, StudentName="Nahid", Number =95},
new Student{StudentID=10, StudentName="Asraf", Number =95},
new Student{StudentID=11, StudentName="Asfaq", Number =85},
new Student{StudentID=12, StudentName="kbil", Number =95},
new Student{StudentID=13, StudentName="Masum", Number =95},
new Student{StudentID=14, StudentName="Nasid", Number =45},
new Student{StudentID=15, StudentName="Babu", Number =75},
new Student{StudentID=16, StudentName="Titu", Number =85}
};
return StudentStudents;
}
public class Student
{
public int StudentID { get; set; }
public string StudentName { get; set; }
public int Number{ get; set; }
}
}