private void BindDataGridDetails(string p)
{
var allClients = new List<DataLayer.Client>();
if (string.IsNullOrWhiteSpace(p))
{
allClients = entities.Clients.ToList();
}
else
{
allClients = entities.Clients.Where(m =>m.CompanyName.Contains(p)||m.ContactPersonName.Contains(p)).ToList();
}
allClients = entities.Clients.ToList();
var finalClientList = allClients.Select(v => new
{
v.UserId,
v.MobileNumber,
v.Designation,
v.CompanyName,
v.ContactPersonName,
EmailAddress = v.User.EmailAddress,
status = v.User.Status.Name
}).ToList();
Gdview.DataSource = finalClientList;
Gdview.DataBind();
}
以下是必需的数据库表
User(id,statusid,emailaddress)
client(id,userid,designation,mobilenumber,companyname,contactperson)
status(statusid,statusname)