ASPX templates
Version 5.x > ASPX templates > Binding CustomTableDataSource with Drop-Down List View modes: 
User avatar
Member
Member
eric.rovtar-hudsonchapel - 1/18/2011 3:11:32 PM
   
Binding CustomTableDataSource with Drop-Down List
Hi!

How do I go about binding a CustomTableDataSource with a Drop-Down List?


<cms:CustomTableDataSource ID="ctdsCampuses"
CustomTable="general.campuses"
SelectedColumns="Name, ItemID"
OrderBy="Name ASC"
runat="server" />

<asp:DropDownList ID="ddlCampusSelect" DataSourceID="ctdsCampuses" runat="server">
</asp:DropDownList>


Using this, I get the following error:

The DataSourceID of 'ddlCampusSelect' must be the ID of a control of type IDataSource. 'ctdsCampuses' is not an IDataSource.

I looked in the CustomTable and DataSource examples, but didn't see an answer.

Thanks!

-Eric

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 1/19/2011 11:12:44 AM
   
RE:Binding CustomTableDataSource with Drop-Down List
Hi Eric,

please take a look at the following example:

1. aspx page:

<cms:CustomTableDataSource ID="ctdsCampuses" runat="server" />
<asp:DropDownList ID="ddlCampusSelect" runat="server"> </asp:DropDownList>


2. code behind:


protected void Page_Load(object sender, EventArgs e)
{
ctdsCampuses.CustomTable = "customtable.town";
ctdsCampuses.SelectedColumns = "ItemID,Town";

ddlCampusSelect.DataSource = ctdsCampuses.DataSource;
ddlCampusSelect.DataValueField = "ItemID";
ddlCampusSelect.DataTextField = "Town";
ddlCampusSelect.DataBind();
}


Best regards,
Ivana Tomanickova

User avatar
Member
Member
eric.rovtar - 1/19/2011 9:52:37 PM
   
RE:Binding CustomTableDataSource with Drop-Down List
Sorry, but that doesn't work. I'm on 5.5R2 and just applied the latest build. I get this error:

CS1061: 'ASP.cmswebparts_customtables_customtabledatasource_ascx' does not contain a definition for 'DataSource' and no extension method 'DataSource' accepting a first argument of type 'ASP.cmswebparts_customtables_customtabledatasource_ascx' could be found (are you missing a using directive or an assembly reference?)

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 1/20/2011 3:49:55 AM
   
RE:Binding CustomTableDataSource with Drop-Down List
Hi Eric,

The DataSource property is not available for the CustomTableDataSource webpart. Could you please try to use CustomTableDataSource control instead?

Best regards,
Ivana Tomanickova