Update XML entries in XML template via datagrid update command handlerhttp://forums.asp.net/t/1780891.aspx/1?Update+XML+entries+in+XML+template+via+datagrid+update+command+handlerSat, 17 Mar 2012 00:17:14 -040017808914882685http://forums.asp.net/p/1780891/4882685.aspx/1?Update+XML+entries+in+XML+template+via+datagrid+update+command+handlerUpdate XML entries in XML template via datagrid update command handler <p>Hello everybody,&nbsp;</p> <p>i have issue with update command. So here is the thing. I want to make a XML translator. In left column one language and on the right side .. another language. When i click on edit button right side text transforms in to empty WYSIWYG text editor. After i type text there i need to put typed text in to XML template, which is generated from original XML with filled elements.<br> <strong>Original XML:</strong></p> <pre class="prettyprint">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt; &lt;dataroot&gt; &lt;index&gt; &lt;key&gt;global_header_country_name&lt;/key&gt; &lt;text&gt; Lietuva &lt;/text&gt; &lt;/index&gt; &lt;index&gt; &lt;key&gt;index_new_information_box_sub_title_text1&lt;/key&gt; &lt;text&gt; Lietuvoje elektronines sskaitas faktras reglamentuoja &lt;a href=&quot;http://www3.lrs.lt/pls/inter3/dokpaieska.showdoc_l?p_id=389443&quot; target=&quot;_blank&quot;&gt;PVM statymas&lt;/a&gt; bei VMI ileistos Elektronini pridtins verts mokesio sskait faktr iraymo, isiuntimo ir saugojimo taisykls &lt;a href=&quot;http://www3.lrs.lt/pls/inter3/dokpaieska.showdoc_l?p_id=358040&quot; target=&quot;_blank&quot;&gt;VA-80&lt;/a&gt;. &lt;/text&gt; &lt;/index&gt; &lt;index&gt; &lt;key&gt;recipients_page_description&lt;/key&gt; &lt;text&gt; Paslaugos gavjams - Elektronins sskaitos faktros &lt;/text&gt; &lt;/index&gt; &lt;index&gt; &lt;key&gt;index_new_information_box_sub_title_text2&lt;/key&gt; &lt;text&gt; Lietuvoje elektronines sskaitas faktras reglamentuoja &lt;a href=&quot;http://www3.lrs.lt/pls/inter3/dokpaieska.showdoc_l?p_id=389443&quot; target=&quot;_blank&quot;&gt;PVM statymas&lt;/a&gt; bei VMI ileistos Elektronini pridtins verts mokesio sskait faktr iraymo, isiuntimo ir saugojimo taisykls &lt;a href=&quot;http://www3.lrs.lt/pls/inter3/dokpaieska.showdoc_l?p_id=358040&quot; target=&quot;_blank&quot;&gt;VA-80&lt;/a&gt;. &lt;/text&gt; &lt;/index&gt; &lt;/dataroot&gt;</pre> <p><strong>Generated XML:</strong></p> <pre class="prettyprint">&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;dataroot&gt; &lt;index&gt; &lt;key&gt;global_header_country_name&lt;/key&gt; &lt;text&gt; &lt;/text&gt; &lt;/index&gt; &lt;index&gt; &lt;key&gt;index_new_information_box_sub_title_text1&lt;/key&gt; &lt;text&gt; &lt;/text&gt; &lt;/index&gt; &lt;index&gt; &lt;key&gt;recipients_page_description&lt;/key&gt; &lt;text&gt; &lt;/text&gt; &lt;/index&gt; &lt;index&gt; &lt;key&gt;index_new_information_box_sub_title_text2&lt;/key&gt; &lt;text&gt; &lt;/text&gt; &lt;/index&gt; &lt;/dataroot&gt;</pre> <p>So as you can see everything stayd at theis places, only &lt;text&gt; &lt;/text&gt; are empyt. This is the place where i need to put transladet text from Rich Text Editor to XML via DataGrid - update command.</p> <p><br /><strong>I have data grid, it looks like this:</strong></p> <pre class="prettyprint">&lt;asp:DataGrid ID="ItemsGrid" runat="server" AllowPaging="True" OnUpdateCommand="ItemsGrid_UpdateCommand" OnEditCommand="ItemsGrid_EditCommand" OnCancelCommand="ItemsGrid_CancelCommand" AllowCustomPaging="True" AutoGenerateColumns="False" &gt; &lt;Columns&gt; &lt;asp:EditCommandColumn EditText="Edit" CancelText="Cancel" UpdateText="Update" /&gt; &lt;asp:TemplateColumn ItemStyle-Width="435"&gt; &lt;ItemTemplate&gt; &lt;asp:Literal runat="server" ID="ItemsGrid_raktas" Text='&lt;%# Eval("key")%&gt;'&gt;&lt;/asp:Literal&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateColumn&gt; &lt;asp:TemplateColumn ItemStyle-Width="435"&gt; &lt;ItemTemplate&gt; &lt;asp:Literal runat="server" ID="ItemsGrid_veciamas" Text='&lt;%# Eval("text_source")%&gt;'&gt;&lt;/asp:Literal&gt; &lt;/ItemTemplate&gt; &lt;ItemStyle Width="435px"&gt;&lt;/ItemStyle&gt; &lt;/asp:TemplateColumn&gt; &lt;asp:TemplateColumn&gt; &lt;/asp:TemplateColumn&gt; &lt;asp:TemplateColumn ItemStyle-Width="565"&gt; &lt;ItemTemplate&gt; &lt;asp:Literal runat="server" ID="ItemsGrid_isverstas_Pasivus" Text='&lt;%# Eval("text_destination") %&gt;'&gt;&lt;/asp:Literal&gt; &lt;/ItemTemplate&gt; &lt;EditItemTemplate&gt; &lt;FTB:FreeTextBox ID="tvarkykle" Text='&lt;%# Eval("text_destination") %&gt;' runat="server"&gt; &lt;/FTB:FreeTextBox&gt; &lt;/EditItemTemplate&gt; &lt;ItemStyle Width="565px"&gt;&lt;/ItemStyle&gt; &lt;/asp:TemplateColumn&gt; &lt;/Columns&gt; &lt;PagerStyle Mode="NumericPages" /&gt; &lt;/asp:DataGrid&gt;</pre> <p>&nbsp;I searched all over the internet for right example of update function for my situation. Maybe somebody can suggest something? Or explain me how it should work &nbsp;or provide some example ?&nbsp;<br> <br> Probably it will be an easy one, but I`am just a beginner at asp .net&nbsp;</p> <p></p> <p>Regards!</p> 2012-03-16T00:46:32-04:004883920http://forums.asp.net/p/1780891/4883920.aspx/1?Re+Update+XML+entries+in+XML+template+via+datagrid+update+command+handlerRe: Update XML entries in XML template via datagrid update command handler <p>Please refer <a href="http://csharpdotnetfreak.blogspot.com/2011/12/gridview-xml-edit-delete-insert-update.html"> Insert Edit Update GridView With XML Data</a></p> 2012-03-16T12:35:43-04:004884094http://forums.asp.net/p/1780891/4884094.aspx/1?Re+Update+XML+entries+in+XML+template+via+datagrid+update+command+handlerRe: Update XML entries in XML template via datagrid update command handler <p>Thank you for example. But this example is on old Framework or something like that. My project is in 4.0 and there is no such namespace like System.Linq, o such command like Rows and so on.</p> 2012-03-16T14:07:21-04:004884763http://forums.asp.net/p/1780891/4884763.aspx/1?Re+Update+XML+entries+in+XML+template+via+datagrid+update+command+handlerRe: Update XML entries in XML template via datagrid update command handler <p>So i found the solution for my issue.</p> <p></p> <pre class="prettyprint">protected void ItemsGrid_UpdateCommand(Object sender, DataGridCommandEventArgs e) { XmlDocument saltinis = new XmlDocument(); saltinis.Load(this.KeliasVerciamasXML); // Prideda elementus. XmlNodeList list = saltinis.GetElementsByTagName(&quot;index&quot;); foreach (XmlNode Item in list) { if (Item.ChildNodes[0].InnerText == ((Literal)e.Item.Cells[1].FindControl(&quot;ItemsGrid_raktas&quot;)).Text) { Item.ChildNodes[1].InnerText = ((FreeTextBox)e.Item.Cells[4].FindControl(&quot;tvarkykle&quot;)).Text; } } XmlTextWriter writer = new XmlTextWriter(this.KeliasIsverstasXML, Encoding.UTF8); writer.Formatting = Formatting.Indented; saltinis.Save(writer); writer.Close(); ItemsGrid.EditItemIndex = -1; this.bindGrid(); }</pre> 2012-03-17T00:17:14-04:00