在kentico 8中循环浏览自定义资源文件

史蒂文·韦伯

我建立了一个.aspx包含下拉菜单模板(没有.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>

此下拉列表应包含所有国家/地区。所有国家/地区都存储在Kentico特定Custom.resexCMSResoures文件夹中。

现在,我想遍历文件并将国家列表传递给转发器。我无法为此找到解决方案。

当然,使用KenticoResHelper.GetString("stringKey")函数通过键获取特定值很容易,但是找不到使用Kentico库接收所有条目的方法。

杰里克

如果您想以超级简单的方式执行此操作,则只需注册在〜/ CMSFormControls / CountrySelector.ascx中找到的“国家/地区选择器”,如下所示:

它具有与您正在处理的功能相同的功能。

但是,为了将来参考,所有国家/地区已经存储在数据库的CMS_Countries表中。用所有国家/地区填充数据集,然后将数据集分配为转发器的数据源会容易得多。这是执行此操作的众多方法之一:

//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文件,则应签出。如何用XML填充数据表

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

在kentico 8中循环浏览自定义资源文件

来自分类Dev

Kentico中的AddAttachment方法

来自分类Dev

Kentico 中的页面列表

来自分类Dev

在kentico cms中插入图像

来自分类Dev

Kentico Trim在Eval的转型中

来自分类Dev

在Kentico中显示外部数据

来自分类Dev

在kentico cms中插入图像

来自分类Dev

Kentico Trim在Eval的转型中

来自分类Dev

利用Kentico的许可来许可自定义模块

来自分类Dev

使用Kentico 9以自定义格式加载数据

来自分类Dev

Kentico Admin-页面类型自定义表单布局

来自分类Dev

Kentico 自定义表数据编辑问题

来自分类Dev

使用自定义页面类型上传的文件的Kentico文件URL

来自分类Dev

从 Kentico 10 中的自定义表转发器中过滤重复的列值

来自分类Dev

在Kentico自定义对象宏方法中访问嵌套属性

来自分类Dev

您可以从自定义的Kentico全局事件处理程序中执行javascript吗?

来自分类Dev

如何在Kentico存储设置中传播舍入配置以进行自定义计算?

来自分类Dev

UI,用于在Kentico的自定义模块中管理类之间的一对多关系

来自分类Dev

大文件上的Kentico同步404错误

来自分类Dev

批准和拒绝文件在Kentico 9

来自分类Dev

Kentico MVC中的内置小部件?

来自分类Dev

Kentico 中继器中的 WHERE 状态

来自分类Dev

Kentico 管理页面中没有图标

来自分类Dev

具有多个相似方面的 Kentico 自定义 Lucene 索引 - 如何查询?

来自分类Dev

如何向 Kentico 新网站向导添加自定义母版页选项

来自分类Dev

Kentico - 从自定义页面类型获取图像的绝对(完整)url

来自分类Dev

Kentico DateTime WebPart 不适用于自定义时区

来自分类Dev

Kentico Portal中的Kentico Kontent DeliveryClient.Build无法加载文件或程序集Microsoft.Extensions.DependencyInjection

来自分类Dev

如何使用文件流创建Kentico媒体库文件

Related 相关文章

  1. 1

    在kentico 8中循环浏览自定义资源文件

  2. 2

    Kentico中的AddAttachment方法

  3. 3

    Kentico 中的页面列表

  4. 4

    在kentico cms中插入图像

  5. 5

    Kentico Trim在Eval的转型中

  6. 6

    在Kentico中显示外部数据

  7. 7

    在kentico cms中插入图像

  8. 8

    Kentico Trim在Eval的转型中

  9. 9

    利用Kentico的许可来许可自定义模块

  10. 10

    使用Kentico 9以自定义格式加载数据

  11. 11

    Kentico Admin-页面类型自定义表单布局

  12. 12

    Kentico 自定义表数据编辑问题

  13. 13

    使用自定义页面类型上传的文件的Kentico文件URL

  14. 14

    从 Kentico 10 中的自定义表转发器中过滤重复的列值

  15. 15

    在Kentico自定义对象宏方法中访问嵌套属性

  16. 16

    您可以从自定义的Kentico全局事件处理程序中执行javascript吗?

  17. 17

    如何在Kentico存储设置中传播舍入配置以进行自定义计算?

  18. 18

    UI,用于在Kentico的自定义模块中管理类之间的一对多关系

  19. 19

    大文件上的Kentico同步404错误

  20. 20

    批准和拒绝文件在Kentico 9

  21. 21

    Kentico MVC中的内置小部件?

  22. 22

    Kentico 中继器中的 WHERE 状态

  23. 23

    Kentico 管理页面中没有图标

  24. 24

    具有多个相似方面的 Kentico 自定义 Lucene 索引 - 如何查询?

  25. 25

    如何向 Kentico 新网站向导添加自定义母版页选项

  26. 26

    Kentico - 从自定义页面类型获取图像的绝对(完整)url

  27. 27

    Kentico DateTime WebPart 不适用于自定义时区

  28. 28

    Kentico Portal中的Kentico Kontent DeliveryClient.Build无法加载文件或程序集Microsoft.Extensions.DependencyInjection

  29. 29

    如何使用文件流创建Kentico媒体库文件

热门标签

归档