Jan 31, 2011, 12:51 AM
Problems displaying DataView
This is almost driving me nuts.
I have a simple .aspx with the following:
The DataView has implicitly and from code behind also assigned the StoreId, so what in the world am I doing wrong?!
I have a simple .aspx with the following:
<style type="text/css">
.categories-view .link-wrap{
float: left;
margin: 4px;
margin-right: 0;
padding: 5px;
text-align:left;
}
</style>
<ext:Portlet runat="server"
ID="pletLeft"
AutoHeight="true"
Draggable="false"
Cls="categories-view"
Layout="Fit"
Collapsible="false">
<Content>
<ext:Store runat="server" ID="storeCategories" AutoLoad="true">
<Reader>
<ext:JsonReader>
<Fields>
<ext:RecordField Name="Department"></ext:RecordField>
<ext:RecordField Name="Name"></ext:RecordField>
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
<ext:DataView ID="dvCategories" runat="server"
StoreID="storeCategories"
AutoHeight="true"
MultiSelect="false"
ItemSelector="div.link-wrap"
EmptyText="No hay categorías">
<Template runat="server">
<Html>
<b>Categorías</b>
<br />
<tpl for=".">
<div class="link-wrap" id="{Department}">
<ext:LinkButton runat="server" text="{Name}"></ext:LinkButton>
</div>
</tpl>
</Html>
</Template>
</ext:DataView>
</Content>
</ext:Portlet>
In my code behind, on the load event I call a function named "LoadCategories", where I set the datasource for the Store.protected void Page_Load(object sender, EventArgs e)
{
try
{
//First, retrieve the department information
intDepartmentId = int.Parse(Request.QueryString.Get("id"));
objDepartment = objPTEntities.Departments.Where(d => d.Department1 == intDepartmentId).FirstOrDefault();
//Load the categories store for the left side pane
LoadCategories();
}
catch (PortaTui.DLL.General.ApplicationException ax)
{
ErrorLog.AddEntry(ErrorLog.ErrorSource.ASPX, System.Web.HttpContext.Current.Request.Url.AbsolutePath, System.Reflection.MethodBase.GetCurrentMethod().Name, ax.ToString(), int.Parse(ax.EventId));
X.Msg.Show(new MessageBoxConfig
{
Title = "Error inesperado",
Message = "Ha ocurrido un error inesperado, por favor intente de nuevo.",
Buttons = MessageBox.Button.OK,
Icon = MessageBox.Icon.ERROR,
AnimEl = this.ClientID
});
}
catch (Exception ex)
{
ErrorLog.AddEntry(ErrorLog.ErrorSource.ASPX, System.Web.HttpContext.Current.Request.Url.AbsolutePath, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.ToString(), 0);
X.Msg.Show(new MessageBoxConfig
{
Title = "Error inesperado",
Message = "Ha ocurrido un error inesperado, por favor intente de nuevo.",
Buttons = MessageBox.Button.OK,
Icon = MessageBox.Icon.ERROR,
AnimEl = this.ClientID
});
}
}
private void LoadCategories()
{
try
{
List<object> objDepartments = new List<object>();
//Add the subdepartments of the selected department
foreach (Department oDepartment in objPTEntities.Departments.Where(d => d.ParentDepartment == objDepartment.Department1).OrderBy(d => d.Priority))
{
objDepartments.Add(new { Department = oDepartment.Department1.ToString(), Name = oDepartment.Name });
}
//Assign the datasource and bind it
storeCategories.DataSource = objDepartments;
storeCategories.DataBind();
dvCategories.StoreID = "storeCategories";
//Validate if categories where loaded, if not, hide the section
if (objDepartments.Count == 0)
dvCategories.Visible = false;
}
catch (PortaTui.DLL.General.ApplicationException ax)
{
ErrorLog.AddEntry(ErrorLog.ErrorSource.ASPX, System.Web.HttpContext.Current.Request.Url.AbsolutePath, System.Reflection.MethodBase.GetCurrentMethod().Name, ax.ToString(), int.Parse(ax.EventId));
X.Msg.Show(new MessageBoxConfig
{
Title = "Error inesperado",
Message = "Ha ocurrido un error inesperado, por favor intente de nuevo.",
Buttons = MessageBox.Button.OK,
Icon = MessageBox.Icon.ERROR,
AnimEl = this.ClientID
});
}
catch (Exception ex)
{
ErrorLog.AddEntry(ErrorLog.ErrorSource.ASPX, System.Web.HttpContext.Current.Request.Url.AbsolutePath, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.ToString(), 0);
X.Msg.Show(new MessageBoxConfig
{
Title = "Error inesperado",
Message = "Ha ocurrido un error inesperado, por favor intente de nuevo.",
Buttons = MessageBox.Button.OK,
Icon = MessageBox.Icon.ERROR,
AnimEl = this.ClientID
});
}
The "objDepartments" list gets populates successfully, however, the first times I got no error but was not being able to display any LinkButton (only a blank line), but without changing much, right now I am getting the following error:The DataView has implicitly and from code behind also assigned the StoreId, so what in the world am I doing wrong?!