Hey everyone,
I've been banging my head against my desk for the last 3 hours trying to get a basic databinding to a gridview. No matter what I seem to do, the gridview always comes back empty. Can anyone offer a suggestion?
aspx:
Code:
1 <es:esDataSource ID="EsDS_SectionTypes" runat="server" OnesCreateEntity="EsDS_SectionTypes_esCreateEntity" OnesSelect="EsDS_SectionTypes_esSelect1" />
2 <div style="float: left;">
3 <asp:GridView ID="GridView1" runat="server" DataSourceID="EsDS_SectionTypes" EmptyDataText="No rows to display">
4 </asp:GridView>
5 </div>
cs:
Code:
1 protected void Page_Load(object sender, EventArgs e)
2 {
3 if (!Page.IsPostBack)
4 {
5 CmsContentSectionTypes entity = new CmsContentSectionTypes();
6 entity.Query.es.CountAll = true;
7 entity.Query.es.CountAllAlias = "Count";
8 if (entity.Query.Load())
9 {
10 //EsDS_SectionTypes.TotalRowCount = (int)entity.GetColumn("Count");
11 }
12 }
13 }
14
15 protected void EsDS_SectionTypes_esSelect1(object sender, EntitySpaces.Web.esDataSourceSelectEventArgs e)
16 {
17 CmsContentSectionTypesCollection collection = new CmsContentSectionTypesCollection();
18
19 // Ensure that there's always a sort to avoid the 'The ranking function "ROW_NUMBER" must have an ORDER BY clause' error
20 //if (e.SortItems == null)
21 //{
22 // collection.Query.OrderBy(collection.Query.Name.Ascending);
23 //}
24
25 // Assign the esDataSourcSelectEvenArgs Collection property
26 //collection.LoadAll();
27
28 //Response.Write("Num rows in collection: " + collection.Count);
29 e.Collection = collection;
30 }
31
32 protected void EsDS_SectionTypes_esCreateEntity(object sender, EntitySpaces.Web.esDataSourceCreateEntityEventArgs e)
33 {
34 CmsContentSectionTypes entity = new CmsContentSectionTypes();
35
36 if (e.PrimaryKeys == null)
37 entity.AddNew();
38 else
39 entity.LoadByPrimaryKey((int)e.PrimaryKeys[0]);
40
41 // Assign the Entity
42 e.Entity = entity;
43 }
Thanks in advance!