1. Show all data
********************************
Output
********************************

********************************
protected void Button1_Click(object sender, EventArgs e)
{
string srt = @"select e.EmployeeId,d.Designation,u.username,u.userpwd from Employees e
inner join DesignationMaster d on d.Designationid=e.DesignationID
inner join userdet u on u.EmpId=e.EmployeeId";
SqlDataAdapter adt = new SqlDataAdapter(srt, con);
DataTable dt = new DataTable();
adt.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
Output
********************************
2. Show all Asst.Professor
********************************
protected void Button2_Click(object sender, EventArgs e)
{
string srt = @"select e.EmployeeId,d.Designation,u.username,u.userpwd from Employees e
inner join DesignationMaster d on d.Designationid=e.DesignationID
inner join userdet u on u.EmpId=e.EmployeeId";
SqlDataAdapter adt = new SqlDataAdapter(srt, con);
DataTable dt = new DataTable();
adt.Fill(dt);
EnumerableRowCollection<DataRow> filter = from row in dt.AsEnumerable() where row.Field<string>("Designation") == "Asst.Professor" select row;
DataView DV = new DataView();
DV = filter.AsDataView();
GridView1.DataSource = DV;
GridView1.DataBind();
}
Output
********************************
3. Filer based on user name
********************************
protected void Button3_Click(object sender, EventArgs e)
{
string srt = @"select e.EmployeeId,d.Designation,u.username,u.userpwd from Employees e
inner join DesignationMaster d on d.Designationid=e.DesignationID
inner join userdet u on u.EmpId=e.EmployeeId";
SqlDataAdapter adt = new SqlDataAdapter(srt, con);
DataTable dt = new DataTable();
adt.Fill(dt);
EnumerableRowCollection<DataRow> filter = from row in dt.AsEnumerable() where row.Field<string>("username").Contains(TextBox1.Text) select row;
DataView dv = new DataView();
dv = filter.AsDataView();
GridView1.DataSource = dv;
GridView1.DataBind();
}
Output
********************************