如何获取下拉列表中使用的listItem的资源值 [英] How to fetch Resource value for listItem which is used in Drop down list

查看:134
本文介绍了如何获取下拉列表中使用的listItem的资源值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我必须在网站上添加包含项目item1和item2的Dropdownlist,但是该item1和item2应该来自不变文化,因此考虑将其添加到资源文件中,但是我的下一个问题是如何从列表项目中获取资源项目? br/>

Hello all,

I have to Add Dropdownlist in my website with items item1 and item2, but this item1 and item2 should be from invariant culture, hence thought to add it in resource file, but my next question is how can I fetch resource items from list items?

<asp:DropDownList ID="DropDownList" runat="server">
<asp:ListItem >Item1
<asp:ListItem>Item2



在Advance中致谢



Thanks in Advance

推荐答案

如果它是不变的,则它不需要在资源中;您只需在代码中的某处将其声明为const字符串即可.

要从嵌入到程序集中的资源中检索信息,请使用 ResourceManager 上的方法> [ ^ ],特别是GetStream,GetString和GetObject.您可以通过
获取当前程序集的资源管理器
If it''s invariant, it doesn''t need to be in a resource; you can just declare it as const string somewhere in your code.

To retrieve information from resources that are embedded into the assembly, use the methods on ResourceManager[^], particularly GetStream, GetString and GetObject. You can get a resource manager for the current assembly via
ResourceManager rm = new ResourceManager("Com.Whatever.ResourceFileName", Assembly.GetExecutingAssembly());


...字符串参数是资源文件的名称(减去.resx和任何区域性后缀).

我链接到的MSDN文章提供了有关卫星组件和其他资源相关材料的更多信息.


... the string argument being the name of the resource file (minus the .resx and any culture suffix).

The MSDN article I linked to has more information about satellite assemblies and other resource related material.


这篇关于如何获取下拉列表中使用的listItem的资源值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆