LCID: how to scaffold language dependent fields from separate tables?http://forums.asp.net/t/1296745.aspx/1?LCID+how+to+scaffold+language+dependent+fields+from+separate+tables+Fri, 01 Aug 2008 11:37:04 -040012967452519397http://forums.asp.net/p/1296745/2519397.aspx/1?LCID+how+to+scaffold+language+dependent+fields+from+separate+tables+LCID: how to scaffold language dependent fields from separate tables? <p>Hi,&nbsp;</p> <p>I have a&nbsp;problem which brings 2 technical questions.<br> I have a <em>Products</em> table with language independent values (like some ID-s, numeric and DateTime values) and <em>ProductDetails</em> table with language dependent values (like Name, Description, etc.).<br> The 2nd table has a column which identifies the language with LCID. The tables have one ot many connection. So I have only one language table no matter how many language I want to support.<br> &nbsp; <br> The first question is how can I display data from <em>ProductDetails</em> depending on the current locale settings? How can I JOIN these tables in the List template view? I also have to display data from the <em>Products</em> table in the same gridview. So if I click on <em>Products </em> in Default.aspx (My tables) I should see rows from<em> Products</em> with values from <em>ProductDetails</em> on the selected language.</p> <p>The secound question is how should I create a form which display input fileds for every language? This Insert/Update template view should display fields for <em>Products</em> table and multiple fields for different languages separated by a tabcontrol (or similar). This form should submit all values at once and insert one row to <em>Products</em> and several to <em>ProductDetails</em>.</p> <p>ex.:</p> <table class=""> <tbody> <tr> <td class="" valign="top" width="140">Category:</td> <td class="" width="305">- select - </td> </tr> <tr> <td class="" valign="top" width="140">Manufacturer:</td> <td class="" width="305">- select - </td> </tr> <tr> <td class="" valign="top" width="140">Item Code:</td> <td class="" width="305">_____________</td> </tr> <tr> <td class="" valign="top" width="140">Weight:</td> <td class="" width="305">_____________</td> </tr> <tr> <td class="" valign="top" width="140">Display:</td> <td class="" width="305">[]</td> </tr> </tbody> </table> <span><strong>hu</strong></span> | <span>en</span> | <span>de</span> | <span>fr</span> -- <em>(select language)</em> <table class="" cellspacing="0" cellpadding="5" border="0"> <tbody> <tr> <td class="" valign="top" width="140"><small>[hu]</small> Type name:</td> <td class="" width="305">_____________</td> </tr> <tr> <td class="" valign="top" width="140"><small>[hu]</small> Price:</td> <td class="" width="305">_____________</td> </tr> <tr> <td class="" valign="top" width="140"><small>[hu]</small> Description:</td> <td class="" width="305">_____________<br> _____________<br> _____________</td> </tr> <tr> <td class="" valign="top" width="140"></td> <td class="" width="305">[SUBMIT] </td> </tr> </tbody> </table> <p>&nbsp;</p> <p>Thanks.</p> 2008-07-28T14:59:58-04:002519602http://forums.asp.net/p/1296745/2519602.aspx/1?Re+LCID+how+to+scaffold+language+dependent+fields+from+separate+tables+Re: LCID: how to scaffold language dependent fields from separate tables? <p>Is it possible to supply a diagram of the relationships </p> <p>e.g.</p> <p><em>Product -&gt; ProductDetails -&gt; Language</em></p> <p>&nbsp;and what fields are linked, the easyist way would be to take a snap shot of the Linq to SQL model designer and pop it on to a google picas account and then post the link here Like this:</p> <p><a href="http://picasaweb.google.com/wizzard1961/WindowsLiveWriter/photo?authkey=muJY8Qx5pCM#5204412692555129810"><img src="http://lh3.ggpht.com/wizzard1961/SDnJxQxIY9I/AAAAAAAAABY/by91LB9_dg0/s400/Northwind%20DBML%5B7%5D.png"></a></p> 2008-07-28T16:08:25-04:002519614http://forums.asp.net/p/1296745/2519614.aspx/1?Re+LCID+how+to+scaffold+language+dependent+fields+from+separate+tables+Re: LCID: how to scaffold language dependent fields from separate tables? <p></p> <blockquote><span class="icon-blockquote"></span> <h4>FTeR</h4> I have a&nbsp;problem which brings 2 technical questions.<br> I have a <em>Products</em> table with language independent values (like some ID-s, numeric and DateTime values) and <em>ProductDetails</em> table with language dependent values (like Name, Description, etc.).<br> The 2nd table has a column which identifies the language with LCID. The tables have one ot many connection. So I have only one language table no matter how many language I want to support.<br> </blockquote> <p>Hi, another question the third table which is linked via LCID does this table contain values or just the language name?</p> 2008-07-28T16:13:51-04:002519659http://forums.asp.net/p/1296745/2519659.aspx/1?Re+LCID+how+to+scaffold+language+dependent+fields+from+separate+tables+Re: LCID: how to scaffold language dependent fields from separate tables? <p>Thanks for the quick answer.</p> <p>Here it is, I truncated the unnecessary fields:<br> <img height="204" src="http://farm4.static.flickr.com/3246/2710139769_9aa80f4cd5_o.jpg" width="447" style="width:447px; height:204px"></p> <p>Here is a good article about the use of&nbsp;LCID in a table structure like this: <a href="http://www.codeproject.com/KB/aspnet/localizationByVivekTakur.aspx"> http://www.codeproject.com/KB/aspnet/localizationByVivekTakur.aspx</a><br> See the last <em>Using a Database for Localization </em>section (he named the column CultureID).</p> <p>&nbsp;Edit: <br> There is no 3rd table. The LCID came from .Net <a href="http://www.microsoft.com/globaldev/reference/lcid-all.mspx"> http://www.microsoft.com/globaldev/reference/lcid-all.mspx</a></p> 2008-07-28T16:38:03-04:002519683http://forums.asp.net/p/1296745/2519683.aspx/1?Re+LCID+how+to+scaffold+language+dependent+fields+from+separate+tables+Re: LCID: how to scaffold language dependent fields from separate tables? <p>Right so let me see if I got this right, </p> <ol> <li>&lt;div mce_keep=&quot;true&quot;&gt;For each product there is one record in the ProductDetail table&lt;/div&gt; </li><li>&lt;div mce_keep=&quot;true&quot;&gt;For each product there are many ProductDetail entries&lt;/div&gt;</li></ol> <p>is it 1 or 2?</p> 2008-07-28T16:48:28-04:002519691http://forums.asp.net/p/1296745/2519691.aspx/1?Re+LCID+how+to+scaffold+language+dependent+fields+from+separate+tables+Re: LCID: how to scaffold language dependent fields from separate tables? <p>2.</p> <p>sry, by language table I meant the <em>ProductDetails</em>, so there is no <em> ProductDetails_En, ProductDetails_De, ProductDetails_Fr</em> or so.</p> 2008-07-28T16:52:01-04:002519724http://forums.asp.net/p/1296745/2519724.aspx/1?Re+LCID+how+to+scaffold+language+dependent+fields+from+separate+tables+Re: LCID: how to scaffold language dependent fields from separate tables? <p>Got that, how is the language selected is it selected on each form or when the user logs on?</p> 2008-07-28T17:05:45-04:002519762http://forums.asp.net/p/1296745/2519762.aspx/1?Re+LCID+how+to+scaffold+language+dependent+fields+from+separate+tables+Re: LCID: how to scaffold language dependent fields from separate tables? <p>This is an administration site with Dynamic Data. So&nbsp;I say both.<br> The admin page sould display data in the prefered language (based on profile or browser settings) in lists (gridview, List.aspx), but when this admin want to upload or modify data, s/he should be able to&nbsp;set values for every language. For the specific fileds there should be a tabcontrol (or so), like in this forum when you Reply (there is Compose, Preview, etc.) only with the same fileds (formview?) asking for the language&nbsp;specific value. When the admin click on submit, than all data sould be inserted to database.</p> 2008-07-28T17:17:23-04:002519786http://forums.asp.net/p/1296745/2519786.aspx/1?Re+LCID+how+to+scaffold+language+dependent+fields+from+separate+tables+Re: LCID: how to scaffold language dependent fields from separate tables? <p>I assume that the number of languages is not fixed, for instance the admin could add a new language at any time. </p> <p>And what about a site with say 2 products with 3 languages and one product with only one language?</p> 2008-07-28T17:27:35-04:002519803http://forums.asp.net/p/1296745/2519803.aspx/1?Re+LCID+how+to+scaffold+language+dependent+fields+from+separate+tables+Re: LCID: how to scaffold language dependent fields from separate tables? <p>Than there&nbsp;are 7 records in <em>ProductDetails</em>.<br> In lists it should list the default language value if no preffered, but it is good enough if it alwas display the default language. The matter is, how to insert/update data.<br> </p> 2008-07-28T17:34:18-04:002519836http://forums.asp.net/p/1296745/2519836.aspx/1?Re+LCID+how+to+scaffold+language+dependent+fields+from+separate+tables+Re: LCID: how to scaffold language dependent fields from separate tables? <p>I have a few ideas I will look into it and get back to you. The problem is awkward not some much difficult [:D]</p> 2008-07-28T17:45:49-04:002519878http://forums.asp.net/p/1296745/2519878.aspx/1?Re+LCID+how+to+scaffold+language+dependent+fields+from+separate+tables+Re: LCID: how to scaffold language dependent fields from separate tables? <p>thank you [8-|]</p> 2008-07-28T17:57:20-04:002519924http://forums.asp.net/p/1296745/2519924.aspx/1?Re+LCID+how+to+scaffold+language+dependent+fields+from+separate+tables+Re: LCID: how to scaffold language dependent fields from separate tables? <p><span>Displaying the languages like below:&nbsp;</span> </p> <p><span><strong>hu</strong></span> | <span>en</span> | <span>de</span> | <span>fr</span>&nbsp; </p> <p>On the page are you using a table to translate form 1033 (US)&nbsp;or 2057(UK)&nbsp;to <strong> en</strong> etc or some other method</p> 2008-07-28T18:10:49-04:002519972http://forums.asp.net/p/1296745/2519972.aspx/1?Re+LCID+how+to+scaffold+language+dependent+fields+from+separate+tables+Re: LCID: how to scaffold language dependent fields from separate tables? <p>I have nothing so far, I copied that structure from one of my php project (I'm about to migrate it) it simple use these chars.<br> I think I'll use some other method (a built in property or something) or maybe I'll not make that restriction if the client whant to make differenc, then s/he have the option.</p> 2008-07-28T18:28:45-04:002519987http://forums.asp.net/p/1296745/2519987.aspx/1?Re+LCID+how+to+scaffold+language+dependent+fields+from+separate+tables+Re: LCID: how to scaffold language dependent fields from separate tables? <p>DynamicData would display data based on the Culture property of the page. you can programtically change the culture property based on the current language selection by the user from the &quot;select language&quot; option on the page.The <b>Culture</b> value determines the results of culture-dependent functions, such as the date, number, and currency formatting, and so on</p> <p><a href="http://msdn.microsoft.com/en-us/library/bz9tc508(VS.85).aspx">http://msdn.microsoft.com/en-us/library/bz9tc508(VS.85).aspx</a></p> <p>&nbsp;</p> <p>&nbsp;</p> 2008-07-28T18:33:38-04:002520035http://forums.asp.net/p/1296745/2520035.aspx/1?Re+LCID+how+to+scaffold+language+dependent+fields+from+separate+tables+Re: LCID: how to scaffold language dependent fields from separate tables? <p>You say I sholud store UICulture values insted of LCID?</p> 2008-07-28T18:46:47-04:002522973http://forums.asp.net/p/1296745/2522973.aspx/1?Re+LCID+how+to+scaffold+language+dependent+fields+from+separate+tables+Re: LCID: how to scaffold language dependent fields from separate tables? <p>Hi FTeR, I've had a good look around and can't find a way to use the <strong>ajax toolkit tab container</strong> to seperate the languages on the page using either <strong><a class="" href="http://weblogs.asp.net/scottgu/archive/2007/08/10/the-asp-listview-control-part-1-building-a-product-listing-page-with-clean-css-ui.aspx">ListView</a></strong> or <strong>Repeater</strong> I've had a look around and can't see a simple solution to the tabs.</p> <p>For showing all languages at once, I would use custome pages like <a class="" href="http://csharpbits.notaclue.net/2008/07/part-4-detailsview-and-gridview-with.html"> here</a> on my blog and to restrict ordinary users to their own language I woudl use this trick <a class="" href="http://csharpbits.notaclue.net/2008/06/dynamicdata-limit-data-displayed-by.html"> here</a>&nbsp;and then use this code to get and set the language:</p> <pre class="prettyprint">var cultureCode = CultureInfo.CurrentCulture.TwoLetterISOLanguageName;</pre> <P>&nbsp;Getting the culture two letter code</P> <P>and use this sample code to get a list of posible cultures:&nbsp; <pre class="prettyprint"><SPAN class=kwd>using</SPAN> System; <SPAN class=kwd>using</SPAN> System.Globalization; <SPAN class=kwd>namespace</SPAN> LCID { <SPAN class=kwd>class</SPAN> Program { <SPAN class=kwd>static void</SPAN> Main(<SPAN class=kwd>string</SPAN>[] args) { <SPAN class=cmt>// Displays several properties of the neutral cultures.</SPAN> Console.Write(<SPAN class=st>"{0,-16}"</SPAN>, <SPAN class=st>"CULTURE"</SPAN>); Console.Write(<SPAN class=st>" {0,-3}"</SPAN>, <SPAN class=st>"ISO"</SPAN>); Console.Write(<SPAN class=st>" {0,-3}"</SPAN>, <SPAN class=st>"ISO"</SPAN>); Console.Write(<SPAN class=st>" {0,-3}"</SPAN>, <SPAN class=st>"WIN"</SPAN>); Console.Write(<SPAN class=st>" {0,-45}"</SPAN>, <SPAN class=st>"DISPLAYNAME"</SPAN>); Console.WriteLine(<SPAN class=st>" {0,-45}"</SPAN>, <SPAN class=st>"ENGLISHNAME"</SPAN>); <SPAN class=kwd>foreach</SPAN> (CultureInfo ci <SPAN class=kwd>in</SPAN> CultureInfo.GetCultures(CultureTypes.NeutralCultures)) { Console.Write(<SPAN class=st>"{0,-16}"</SPAN>, ci.Name); Console.Write(<SPAN class=st>" {0,-3}"</SPAN>, ci.TwoLetterISOLanguageName); Console.Write(<SPAN class=st>" {0,-3}"</SPAN>, ci.ThreeLetterISOLanguageName); Console.Write(<SPAN class=st>" {0,-3}"</SPAN>, ci.ThreeLetterWindowsLanguageName); Console.Write(<SPAN class=st>" {0,-45}"</SPAN>, ci.DisplayName); Console.WriteLine(<SPAN class=st>" {0,-45}"</SPAN>, ci.EnglishName); } } } }</pre> <p>the above is a command line app but is just a sample to get the list of culture codes</p> <p>Hope this helps [:D]</p> 2008-07-29T19:13:53-04:002523091http://forums.asp.net/p/1296745/2523091.aspx/1?Re+LCID+how+to+scaffold+language+dependent+fields+from+separate+tables+Re: LCID: how to scaffold language dependent fields from separate tables? <p>Thank you very much!</p> <p>I had a look on that Part 4 article, I do not say I understand it all, but I will try my best ;) So you say I should use a GridView for the language dependent value where every language is row?<br> Where were you try to use a&nbsp;Repeater? The answer may help me better understand the overall logic.</p> <p>What should I do for the List.aspx page template? Should I list the values from <em>ProductDetails</em> grouped by the ProductID or list rows from <em>Products</em> and somehow join data from <em>ProductDetails</em>? </p> <p>Thank you again!</p> 2008-07-29T20:00:43-04:002523398http://forums.asp.net/p/1296745/2523398.aspx/1?Re+LCID+how+to+scaffold+language+dependent+fields+from+separate+tables+Re: LCID: how to scaffold language dependent fields from separate tables? <p>Yes have a go and I think I have a trick for the tabs, which I'll post once I've done it [:D]</p> 2008-07-30T00:00:19-04:002524821http://forums.asp.net/p/1296745/2524821.aspx/1?Re+LCID+how+to+scaffold+language+dependent+fields+from+separate+tables+Re: LCID: how to scaffold language dependent fields from separate tables? <p>Hi FTer here is the tabs answer</p> <p><img src="http://lh5.ggpht.com/wizzard1961/SJBc9AZYY-I/AAAAAAAAANg/3KS7rgLsJEw/s800/ScreenShot077.png.jpg"> </p> <p>Heres the page code:</p> <pre class="prettyprint">&lt;%@ Page Language=&quot;C#&quot; MasterPageFile=&quot;~/Site.master&quot; CodeFile=&quot;Edit.aspx.cs&quot; Inherits=&quot;Edit&quot; %&gt; &lt;asp:Content ID=&quot;Content1&quot; ContentPlaceHolderID=&quot;ContentPlaceHolder1&quot; runat=&quot;Server&quot;&gt; &lt;asp:DynamicDataManager runat=&quot;server&quot; ID=&quot;DynamicDataManager1&quot; AutoLoadForeignKeys=&quot;true&quot; /&gt; &lt;h2&gt;Edit entry from table &lt;%= mtProducts.DisplayName %&gt;&lt;/h2&gt; &lt;asp:ScriptManagerProxy runat=&quot;server&quot; ID=&quot;ScriptManagerProxy1&quot; /&gt; &lt;asp:UpdatePanel runat=&quot;server&quot; ID=&quot;UpdatePanel1&quot;&gt; &lt;ContentTemplate&gt; &lt;asp:ValidationSummary runat=&quot;server&quot; ID=&quot;ValidationSummary1&quot; EnableClientScript=&quot;true&quot; HeaderText=&quot;List of validation errors&quot; /&gt; &lt;asp:DynamicValidator runat=&quot;server&quot; ID=&quot;DetailsViewValidator&quot; ControlToValidate=&quot;DetailsView1&quot; Display=&quot;None&quot; /&gt; &lt;asp:DetailsView runat=&quot;server&quot; ID=&quot;DetailsView1&quot; DataSourceID=&quot;ldsProducts&quot; DefaultMode=&quot;Edit&quot; AutoGenerateEditButton=&quot;True&quot; OnItemCommand=&quot;DetailsView1_ItemCommand&quot; OnItemUpdated=&quot;DetailsView1_ItemUpdated&quot; CssClass=&quot;detailstable&quot; FieldHeaderStyle-CssClass=&quot;bold&quot; AutoGenerateRows=&quot;False&quot;&gt; &lt;FieldHeaderStyle CssClass=&quot;bold&quot; /&gt; &lt;Fields&gt; &lt;asp:DynamicField DataField=&quot;Code&quot; /&gt; &lt;asp:DynamicField DataField=&quot;Display&quot; /&gt; &lt;asp:DynamicField DataField=&quot;Inserted&quot; /&gt; &lt;/Fields&gt; &lt;/asp:DetailsView&gt; &lt;asp:LinqDataSource runat=&quot;server&quot; ID=&quot;ldsProducts&quot; ContextTypeName=&quot;ProductsDataContext&quot; TableName=&quot;Products&quot;&gt; &lt;WhereParameters&gt; &lt;asp:Parameter /&gt; &lt;/WhereParameters&gt; &lt;/asp:LinqDataSource&gt; &lt;h2&gt;Tabs&lt;/h2&gt; &lt;asp:ListView ID=&quot;lvLanguages&quot; runat=&quot;server&quot; DataSourceID=&quot;ldsLanguages&quot; DataKeyNames=&quot;LCID&quot;&gt; &lt;LayoutTemplate&gt; &lt;div id=&quot;itemPlaceHolder&quot; runat=&quot;server&quot;&gt;&lt;/div&gt; &lt;/LayoutTemplate&gt; &lt;ItemTemplate&gt; &lt;asp:LinkButton runat=&quot;server&quot; Text='&lt;%# Eval(&quot;LCID&quot;) %&gt;' CommandName=&quot;Select&quot;&gt;&lt;/asp:LinkButton&gt; &lt;/ItemTemplate&gt; &lt;SelectedItemTemplate&gt; &lt;strong&gt;&lt;%# Eval(&quot;LCID&quot;) %&gt;&lt;/strong&gt; &lt;/SelectedItemTemplate&gt; &lt;/asp:ListView&gt; &lt;asp:LinqDataSource ID=&quot;ldsLanguages&quot; runat=&quot;server&quot; ContextTypeName=&quot;ProductsDataContext&quot; TableName=&quot;ProductDetails&quot; Where=&quot;ProductId == @ProductId&quot;&gt; &lt;WhereParameters&gt; &lt;asp:ControlParameter ControlID=&quot;DetailsView1&quot; Name=&quot;ProductId&quot; PropertyName=&quot;SelectedValue&quot; Type=&quot;Int32&quot; /&gt; &lt;/WhereParameters&gt; &lt;/asp:LinqDataSource&gt; &lt;br /&gt;&lt;br /&gt; &lt;asp:GridView ID=&quot;GridView1&quot; runat=&quot;server&quot; AutoGenerateColumns=&quot;False&quot; CssClass=&quot;gridview&quot; DataKeyNames=&quot;Id&quot; DataSourceID=&quot;ldsProductDetails&quot;&gt; &lt;Columns&gt; &lt;asp:CommandField ShowEditButton=&quot;True&quot; /&gt; &lt;asp:BoundField DataField=&quot;Type&quot; HeaderText=&quot;Type&quot; SortExpression=&quot;Type&quot; /&gt; &lt;asp:BoundField DataField=&quot;Price&quot; HeaderText=&quot;Price&quot; SortExpression=&quot;Price&quot; /&gt; &lt;asp:BoundField DataField=&quot;Description&quot; HeaderText=&quot;Description&quot; SortExpression=&quot;Description&quot; /&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; &lt;asp:LinqDataSource ID=&quot;ldsProductDetails&quot; runat=&quot;server&quot; ContextTypeName=&quot;ProductsDataContext&quot; EnableUpdate=&quot;True&quot; TableName=&quot;ProductDetails&quot; Where=&quot;LCID == @LCID&quot;&gt; &lt;WhereParameters&gt; &lt;asp:ControlParameter ControlID=&quot;lvLanguages&quot; Name=&quot;LCID&quot; PropertyName=&quot;SelectedValue&quot; Type=&quot;String&quot; /&gt; &lt;/WhereParameters&gt; &lt;/asp:LinqDataSource&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; &lt;/asp:Content&gt;</pre> <P mce_keep="true">heres the code behind:</P><pre class="prettyprint"><SPAN class=kwd>using</SPAN> System; <SPAN class=kwd>using</SPAN> System.Web.DynamicData; <SPAN class=kwd>using</SPAN> System.Web.UI.WebControls; <SPAN class=kwd>public</SPAN> partial <SPAN class=kwd>class</SPAN> Edit : System.Web.UI.Page { <SPAN class=kwd>protected</SPAN> MetaTable mtProducts; <SPAN class=kwd>protected</SPAN> MetaTable mtProductDetails; <SPAN class=kwd>protected void</SPAN> Page_Init(<SPAN class=kwd>object</SPAN> sender, EventArgs e) { DynamicDataManager1.RegisterControl(DetailsView1); DynamicDataManager1.RegisterControl(GridView1); } <SPAN class=kwd>protected void</SPAN> Page_Load(<SPAN class=kwd>object</SPAN> sender, EventArgs e) { mtProducts = ldsProducts.GetTable(); mtProductDetails = ldsProductDetails.GetTable(); Title = mtProducts.DisplayName; } <SPAN class=kwd>protected void</SPAN> DetailsView1_ItemCommand(<SPAN class=kwd>object</SPAN> sender, DetailsViewCommandEventArgs e) { <SPAN class=kwd>if</SPAN> (e.CommandName == DataControlCommands.CancelCommandName) { Response.Redirect(mtProducts.ListActionPath); } } <SPAN class=kwd>protected void</SPAN> DetailsView1_ItemUpdated(<SPAN class=kwd>object</SPAN> sender, DetailsViewUpdatedEventArgs e) { <SPAN class=kwd>if</SPAN> (e.Exception == <SPAN class=kwd>null</SPAN> || e.ExceptionHandled) { Response.Redirect(mtProducts.ListActionPath); } } } </pre> <P>And heres the <STRONG>FieldTemplate</STRONG> for LCID:</P><pre class="prettyprint"><SPAN class=dir>&lt;%@ Control Language="C#" CodeFile="LCID_Edit.ascx.cs" Inherits="LCID_EditField" %&gt;</SPAN> &lt;<SPAN class=tag>asp:DropDownList</SPAN> <SPAN class=attr> runat=</SPAN><SPAN class=attrv>"server"</SPAN> <SPAN class=attr> ID=</SPAN><SPAN class=attrv>"DropDownList1"</SPAN> <SPAN class=attr> CssClass=</SPAN><SPAN class=attrv>"droplist"</SPAN> <SPAN class=attr> ondatabound=</SPAN><SPAN class=attrv>"DropDownList1_DataBound"</SPAN>&gt; &lt;/<SPAN class=tag>asp:DropDownList</SPAN>&gt;</pre> <P mce_keep="true"> <P><STRONG>Code Behind</STRONG></P><pre class="prettyprint"><SPAN class=kwd>using</SPAN> System; <SPAN class=kwd>using</SPAN> System.Collections.Specialized; <SPAN class=kwd>using</SPAN> System.Globalization; <SPAN class=kwd>using</SPAN> System.Linq; <SPAN class=kwd>using</SPAN> System.Web.UI; <SPAN class=kwd>using</SPAN> System.Web.UI.WebControls; <SPAN class=kwd>public</SPAN> partial <SPAN class=kwd>class</SPAN> LCID_EditField : System.Web.DynamicData.FieldTemplateUserControl { <SPAN class=kwd>protected void</SPAN> Page_Load(<SPAN class=kwd>object</SPAN> sender, EventArgs e) { <SPAN class=kwd>if</SPAN> (<SPAN class=kwd>this</SPAN>.Mode == DataBoundControlMode.Insert) { BindCultureToDropdownList(); } } <SPAN class=kwd>protected override void</SPAN> OnDataBinding(EventArgs e) { <SPAN class=kwd>base</SPAN>.OnDataBinding(e); BindCultureToDropdownList(); } <SPAN class=kwd>private void</SPAN> BindCultureToDropdownList() { <SPAN class=cmt>// use linq to get a list of cultures to display in the drop down list</SPAN> var cultures = from c <SPAN class=kwd>in</SPAN> CultureInfo.GetCultures(CultureTypes.NeutralCultures) select <SPAN class=kwd>new</SPAN> { Lcid = c.TwoLetterISOLanguageName, Name = c.TwoLetterISOLanguageName + <SPAN class=st>" - "</SPAN> + c.EnglishName }; <SPAN class=cmt>// setup the drop down list</SPAN> DropDownList1.DataSource = cultures; DropDownList1.DataValueField = <SPAN class=st>"Lcid"</SPAN>; DropDownList1.DataTextField = <SPAN class=st>"Name"</SPAN>; DropDownList1.DataBind(); } <SPAN class=kwd>protected override void</SPAN> ExtractValues(IOrderedDictionary dictionary) { dictionary[Column.Name] = ConvertEditedValue(DropDownList1.SelectedValue); } <SPAN class=kwd>public override</SPAN> Control DataControl { <SPAN class=kwd>get</SPAN> { <SPAN class=kwd>return</SPAN> DropDownList1; } } <SPAN class=kwd>protected void</SPAN> DropDownList1_DataBound(<SPAN class=kwd>object</SPAN> sender, EventArgs e) { <SPAN class=cmt>// if there is nothing is the FieldValueString // set it to the culture of the client session</SPAN> <SPAN class=kwd>if</SPAN> (String.IsNullOrEmpty(FieldValueString)) { DropDownList1.SelectedValue = CultureInfo.CurrentCulture.TwoLetterISOLanguageName; } <SPAN class=kwd>else</SPAN> { <SPAN class=cmt>// set the drop down list to the current vlaue</SPAN> DropDownList1.SelectedValue = FieldValueString; } } } </pre> <p>***UPDATED*** fixed a bg in <strong>FieldTemplate</strong> that stopped it working in Insert mode [:&#36;]&nbsp;</p> <p>Hope this helps [:D]</p> 2008-07-30T12:28:47-04:00