C# 循环浏览kentico 8中的自定义资源文件
我构建了一个C# 循环浏览kentico 8中的自定义资源文件,c#,asp.net,localization,repeater,kentico,C#,Asp.net,Localization,Repeater,Kentico,我构建了一个.aspx模板,其中包含一个下拉列表(no.asp控件) 模板示例: <select> <option selected="selected" value="">Bitte wählen</option> <asp:Repeater ID="countryDropDown" runat="server"> <HeaderTemplate> <o
.aspx
模板,其中包含一个下拉列表(no.asp控件)
模板示例:
<select>
<option selected="selected" value="">Bitte wählen</option>
<asp:Repeater ID="countryDropDown" runat="server">
<HeaderTemplate>
<option value="<%--key--%>">
</HeaderTemplate>
<ItemTemplate>
<%--value--%>
</ItemTemplate>
<FooterTemplate>
</option>
</FooterTemplate>
</asp:Repeater>
</select>
比特wä;赫伦
此下拉列表应包含所有国家/地区。所有国家/地区都存储在Custom.resex
中,该文件夹位于Kentico特定的CMSResoures
文件夹中
现在我想遍历该文件,并将国家列表传递给中继器。
我找不到解决这个问题的办法
当然,使用Kentico
ResHelper.GetString(“stringKey”)
函数通过键很容易获得特定值,但没有找到使用Kentico库接收所有条目的方法 如果您想以超级简单的方式进行此操作,只需注册~/CMSFormControls/CountrySelector.ascx中的国家/地区选择器,如下所示:
它的功能与您正在处理的功能相同
但是,为了将来参考,所有国家/地区都已存储在数据库的CMS_国家/地区表中。用所有国家填充数据集,然后将该数据集指定为中继器的数据源将更容易。以下是实现此目的的众多方法之一:
//Set the connection string to the Kentico Database in the web.config to a variable called CMSConnectionString
string CMSConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["CMSConnectionString"].ConnectionString;
//Sets the text of the query we want to execute on the database to a variable called queryText
string queryText = "SELECT * FROM dbo.CMS_Countries";
//Creates a new instance of the SqlDataAdapter object and calls it "adapter".
//We pass in the text of the query we want to executre on the Kentico database, and the connetion string to the Kentico database.
SqlDataAdapter adapter = new SqlDataAdapter(queryText, CMSConnectionString);
//Creates a new instance of the DataSet object and calls it "countries".
DataSet countries = new DataSet();
//Fills the "countries" dataset with the data retrieved by our query on the Kentico database.
adapter.Fill(countries);
//Sets the datasource of the repeater to the dataset that we just created.
repeater.DataSource = countries;
//Binds the datasource to the repeater server control
repeater.DataBind();
最后,如果您必须使用CMS.resx文件,那么您应该签出