Click here to Skip to main content
15,917,320 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am using global resource in my project.

When I fetch it into using data table, it is not ordered as I stored in the file.

Is there any solution to get the data from resource table in the order I saved?

This is my code.
ResourceFileName = "Resources." + ResourceFileName;                   
DataTable dtOperation;
dtOperation = new DataTable();
            
System.Resources.ResourceManager RM = new System.Resources.ResourceManager(ResourceFileName, System.Reflection.Assembly.Load("App_GlobalResources")); //("Resources.vacation", System.Reflection.Assembly.Load("App_GlobalResources"));
ResourceSet resourceSet = RM.GetResourceSet(CultureInfo.CurrentUICulture, true, true);
          dtOperation.Columns.Add("resValue");
          dtOperation.Columns.Add("resKey");
          foreach (DictionaryEntry entry in resourceSet)
           {                    
                DataRow dr = dtOperation.NewRow();
                dr[0] = (String)entry.Value;
                dr[1] =(String)entry.Key;
                dtOperation.Rows.Add(dr);                   
           }    
return dtOperation;
Posted
Updated 24-Jan-11 21:52pm
v3
Comments
m@dhu 25-Jan-11 3:46am    
Edited for the code block.
Dalek Dave 25-Jan-11 3:52am    
Edited for Readability.

1 solution

MSDN Page[^]

Although why it should matter what order it is loaded is beyond me.
Once loaded, simply reorder the table.
 
Share this answer
 
Comments
abdu_karami 25-Jan-11 4:06am    
thanks for ur commnt...
actually..there are so many resource table and the above fuction z common for all. It wil print all the values in a table. For ex: I have employee name, emplyeeid, emplyeeAge etc. But what wil happen if empAge comes 1st and name comes lasr..?
gammagtmw 25-Jan-11 4:32am    
seems to me like you're using the resources for something they're not meant to. Think about using some kind of database for that. XML for example. Not so hard to handle. Even a simple csv might be better for that :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900