Hello,
I am trying to archive the following:
Attach a Telerik Radgrid to a LLBLGenProDatasource2, then allow for the radgrid standard filtering and sorting without (extra) calls to the database. The grid does not require any update/delete/create so I only require a single fetch to the database.
I tried to archieve this putting a EntityCollection in Session and wireup the PerformSelect.
On the first hit (Page is Not Postback) the getData method is executed and the list in Session is loaded with data. However in the same call, in the PerformSelect method the session list is empty again, causing an empty grid.
I use the following code:
ascx user control:
<llblgenpro:LLBLGenProDataSource2 ID="LLBLGUserdata" runat="server"
DataContainerType="EntityCollection" LivePersistence="false"
onperformselect="LLBLGUserdata_PerformSelect" SortingMode="ClientSide" >
</llblgenpro:LLBLGenProDataSource2>
private EntityCollection<UserEntity> userList
{
get
{
if (Session["userList"] != null) return (EntityCollection<UserEntity>)Session["userList"];
return null;
}
set
{
Session["userList"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack) getData();
else
{
LLBLGUserdata.AdapterTypeName = "Dotprof.Reunie.Datalayer.DatabaseSpecific.DataAccessAdapter, Dotprof.Reunie.DatalayerDBSpecific";
LLBLGUserdata.EntityFactoryTypeName = "Dotprof.Reunie.Datalayer.FactoryClasses.UserEntityFactory, Dotprof.Reunie.Datalayer";
LLBLGUserdata.EntityCollection = userList;
LLBLGUserdata.DataBind();
}
}
protected void getData()
{
EntityCollection<UserEntity> usercollection = new EntityCollection<UserEntity>();
using (DataAccessAdapter ds = new DataAccessAdapter())
{
IPrefetchPath2 prefetch = new PrefetchPath2((int)EntityType.UserEntity);
RelationPredicateBucket filter = new RelationPredicateBucket();
filter.PredicateExpression.Add(UserFields.PortalId == currentPortal.PortalId);
filter.PredicateExpression.AddWithAnd(UserFields.UserIsActive == true);
filter.PredicateExpression.AddWithAnd(UserFields.UserIsDeleted == false);
ds.FetchEntityCollection(usercollection, filter, prefetch);
}
userList = usercollection;
LLBLGUserdata.AdapterTypeName = "Dotprof.Reunie.Datalayer.DatabaseSpecific.DataAccessAdapter, Dotprof.Reunie.DatalayerDBSpecific";
LLBLGUserdata.EntityFactoryTypeName = "Dotprof.Reunie.Datalayer.FactoryClasses.UserEntityFactory, Dotprof.Reunie.Datalayer";
LLBLGUserdata.EntityCollection = usercollection;
LLBLGUserdata.DataBind();
}
protected void LLBLGUserdata_PerformSelect(object sender, PerformSelectEventArgs2 e)
{
e.ContainedCollection.AddRange(userList);
}