Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 循环浏览kentico 8中的自定义资源文件_C#_Asp.net_Localization_Repeater_Kentico - Fatal编程技术网

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&auml;hlen</option> <asp:Repeater ID="countryDropDown" runat="server"> <HeaderTemplate> <o

我构建了一个
.aspx
模板,其中包含一个下拉列表(no.asp控件)

模板示例:

<select>
    <option selected="selected" value="">Bitte w&auml;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文件,那么您应该签出