var BusinessPlanID = Convert.ToInt32(ddlSearchBuisnessPlan.SelectedValue.ToString());
var CategoryID = Convert.ToInt32(ddlSearchCategory.SelectedValue.ToString());
var StratergicTypeID = Convert.ToInt32(ddlSearchStratergicType.SelectedValue.ToString());
var StatusID = Convert.ToInt32(ddlSearchStatus.SelectedValue.ToString());
var OsoId = Convert.ToInt32(ddlSearchOso.SelectedValue.ToString());
IQueryable<View_Initiative> query = db.View_Initiative.Where(x => x.IsDeleted == 0);
if (BusinessPlanID != 0)
{
query = query.Where(p => p.BusinessPlanID == BusinessPlanID);
}
if (CategoryID != 0)
{
query = query.Where(p => p.InitiativesCategoryID == CategoryID);
}
if (StratergicTypeID != 0)
{
query = query.Where(p => p.StratgyTypeID == StratergicTypeID);
}
if (OsoId != 0)
{
query = query.Where(p => p.RelatedOsoOrMarketID == OsoId);
}
if (StatusID != 0)
{
query = query.Where(p => p.ProcessStagesID == StatusID);
}
var fetchedresult = query.ToList().Select(t => new
{
INITIATIVETITLE = (t.InitiativeTitle),
TARGETVALUE = (t.TargetValue),
TARGETDESCRIPTION = (t.TargetDescription),
FROMDATE = (t.FromDate),
TODATE = (t.ToDate),
EXPECTEDINCREMENTALBUSINESS = (t.ExpectedIncrementalBusiness),
REQUESTEDBUDGETBYOSO = (t.RequestedBudgetByOSO),
APPROVEDBUDGET = (t.ApprovedBudget),
InitiativesPkID = (t.InitiativesPkID),
KpiWeightage = (t.KpiWeight),
InitiativeCAtegory = (db.MstrInitiativeCategories.Where(x => x.InitiativeCategoryPkID == t.InitiativesCategoryID).FirstOrDefault().InitiativeCategoryName),
Status = (db.MstrProcessStages.Where(x => x.MstrProcessStagesPkID == t.ProcessStagesID).FirstOrDefault().StagesName),
StratergyType = (db.MstrStratergicTypes.Where(x => x.StratergicTypeID == t.StratgyTypeID).FirstOrDefault().StratergicName),
Businessplan = (db.BusinessPlans.Where(x => x.BusinessPlanPkID == t.BusinessPlanID).FirstOrDefault().BusinessPlanName),
OsoName = (db.MstrOSoOfficesMarkets.Where(x => x.OSOOfficesMarketsPkID == t.RelatedOsoOrMarketID).FirstOrDefault().Name),
OsoNameID = t.RelatedOsoOrMarketID
});
GV_List.CurrentPageIndex = 0;
GV_List.DataSource = fetchedresult;
Cache["GridsearchDataSource"] = fetchedresult;
GV_List.DataBind();
var CategoryID = Convert.ToInt32(ddlSearchCategory.SelectedValue.ToString());
var StratergicTypeID = Convert.ToInt32(ddlSearchStratergicType.SelectedValue.ToString());
var StatusID = Convert.ToInt32(ddlSearchStatus.SelectedValue.ToString());
var OsoId = Convert.ToInt32(ddlSearchOso.SelectedValue.ToString());
IQueryable<View_Initiative> query = db.View_Initiative.Where(x => x.IsDeleted == 0);
if (BusinessPlanID != 0)
{
query = query.Where(p => p.BusinessPlanID == BusinessPlanID);
}
if (CategoryID != 0)
{
query = query.Where(p => p.InitiativesCategoryID == CategoryID);
}
if (StratergicTypeID != 0)
{
query = query.Where(p => p.StratgyTypeID == StratergicTypeID);
}
if (OsoId != 0)
{
query = query.Where(p => p.RelatedOsoOrMarketID == OsoId);
}
if (StatusID != 0)
{
query = query.Where(p => p.ProcessStagesID == StatusID);
}
var fetchedresult = query.ToList().Select(t => new
{
INITIATIVETITLE = (t.InitiativeTitle),
TARGETVALUE = (t.TargetValue),
TARGETDESCRIPTION = (t.TargetDescription),
FROMDATE = (t.FromDate),
TODATE = (t.ToDate),
EXPECTEDINCREMENTALBUSINESS = (t.ExpectedIncrementalBusiness),
REQUESTEDBUDGETBYOSO = (t.RequestedBudgetByOSO),
APPROVEDBUDGET = (t.ApprovedBudget),
InitiativesPkID = (t.InitiativesPkID),
KpiWeightage = (t.KpiWeight),
InitiativeCAtegory = (db.MstrInitiativeCategories.Where(x => x.InitiativeCategoryPkID == t.InitiativesCategoryID).FirstOrDefault().InitiativeCategoryName),
Status = (db.MstrProcessStages.Where(x => x.MstrProcessStagesPkID == t.ProcessStagesID).FirstOrDefault().StagesName),
StratergyType = (db.MstrStratergicTypes.Where(x => x.StratergicTypeID == t.StratgyTypeID).FirstOrDefault().StratergicName),
Businessplan = (db.BusinessPlans.Where(x => x.BusinessPlanPkID == t.BusinessPlanID).FirstOrDefault().BusinessPlanName),
OsoName = (db.MstrOSoOfficesMarkets.Where(x => x.OSOOfficesMarketsPkID == t.RelatedOsoOrMarketID).FirstOrDefault().Name),
OsoNameID = t.RelatedOsoOrMarketID
});
GV_List.CurrentPageIndex = 0;
GV_List.DataSource = fetchedresult;
Cache["GridsearchDataSource"] = fetchedresult;
GV_List.DataBind();