Answered by:
load data from resx to ddl

Question
-
User-309740890 posted
Hi,
I am having difficulties loading the data from resx file to ddl control.
Inside the resx file the format is:
Name: CData
Value:
<countries>
<c text="Canada" value="1"/>
<c text="USA" value="2"/>
<c text="Africa" value="3"/>
</countries>
cs file:
ddl.DataSource = this.GetLocalResourceObject("CData");
ddl.DataTextField = "text";
ddl.DataValueField = "value";
ddl.DataBind();
At debug mode, I checked that the data is been capture from resource file as shown above (xml format) But it fails at DataBind(), showing that the text is not found...
Please let me know what am I doing wrong? and if you think the Value in the resource file needs to be different for ddl, please provide me the right format.
Thank you
Tuesday, January 18, 2011 4:20 PM
Answers
-
User191633014 posted
try:
XmlDataSource x = new XmlDataSource (); x.ID = "countries"; x.Data = this.GetLocalResourceObject("CData"); ddl.DataSource = x; ddl.DataTextField = "text"; ddl.DataValueField = "value"; ddl.DataBind();
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, January 18, 2011 5:06 PM
All replies
-
User191633014 posted
try:
XmlDataSource x = new XmlDataSource (); x.ID = "countries"; x.Data = this.GetLocalResourceObject("CData"); ddl.DataSource = x; ddl.DataTextField = "text"; ddl.DataValueField = "value"; ddl.DataBind();
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, January 18, 2011 5:06 PM -
User-309740890 posted
Thanks works. I just had to convert x.Data = this.GetLocalResourceObject("CData"); to Convert.ToString(this.GetLocalResourceObject("CData"));
Is it a good way of capturing the data from the resource file to ddl? or is there a better way of doing it?
Thanks,
Tuesday, January 18, 2011 5:24 PM -
User-309740890 posted
anyone ?
Wednesday, January 19, 2011 2:33 PM