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. Original XML:
<?xml version="1.0" encoding="utf-8" ?>
<dataroot>
<index>
<key>global_header_country_name</key>
<text>
Lietuva
</text>
</index>
<index>
<key>index_new_information_box_sub_title_text1</key>
<text>
Lietuvoje elektronines sąskaitas faktūras reglamentuoja <a href="http://www3.lrs.lt/pls/inter3/dokpaieska.showdoc_l?p_id=389443" target="_blank">PVM įstatymas</a> bei VMI išleistos „Elektroninių pridėtinės vertės mokesčio sąskaitų faktūrų išrašymo, išsiuntimo ir saugojimo taisyklės“ <a href="http://www3.lrs.lt/pls/inter3/dokpaieska.showdoc_l?p_id=358040" target="_blank">VA-80</a>.
</text>
</index>
<index>
<key>recipients_page_description</key>
<text>
Paslaugos gavėjams - Elektroninės sąskaitos faktūros
</text>
</index>
<index>
<key>index_new_information_box_sub_title_text2</key>
<text>
Lietuvoje elektronines sąskaitas faktūras reglamentuoja <a href="http://www3.lrs.lt/pls/inter3/dokpaieska.showdoc_l?p_id=389443" target="_blank">PVM įstatymas</a> bei VMI išleistos „Elektroninių pridėtinės vertės mokesčio sąskaitų faktūrų išrašymo, išsiuntimo ir saugojimo taisyklės“ <a href="http://www3.lrs.lt/pls/inter3/dokpaieska.showdoc_l?p_id=358040" target="_blank">VA-80</a>.
</text>
</index>
</dataroot>
So as you can see everything stayd at theis places, only <text> </text> are empyt. This is the place where i need to put transladet text from Rich Text Editor to XML via DataGrid - update command.
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 or provide some example ?
Probably it will be an easy one, but I`am just a beginner at asp .net
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.
Daniil T.
Member
46 Points
32 Posts
Update XML entries in XML template via datagrid update command handler
Mar 16, 2012 12:46 AM|LINK
Hello everybody,
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.
Original XML:
<?xml version="1.0" encoding="utf-8" ?> <dataroot> <index> <key>global_header_country_name</key> <text> Lietuva </text> </index> <index> <key>index_new_information_box_sub_title_text1</key> <text> Lietuvoje elektronines sąskaitas faktūras reglamentuoja <a href="http://www3.lrs.lt/pls/inter3/dokpaieska.showdoc_l?p_id=389443" target="_blank">PVM įstatymas</a> bei VMI išleistos „Elektroninių pridėtinės vertės mokesčio sąskaitų faktūrų išrašymo, išsiuntimo ir saugojimo taisyklės“ <a href="http://www3.lrs.lt/pls/inter3/dokpaieska.showdoc_l?p_id=358040" target="_blank">VA-80</a>. </text> </index> <index> <key>recipients_page_description</key> <text> Paslaugos gavėjams - Elektroninės sąskaitos faktūros </text> </index> <index> <key>index_new_information_box_sub_title_text2</key> <text> Lietuvoje elektronines sąskaitas faktūras reglamentuoja <a href="http://www3.lrs.lt/pls/inter3/dokpaieska.showdoc_l?p_id=389443" target="_blank">PVM įstatymas</a> bei VMI išleistos „Elektroninių pridėtinės vertės mokesčio sąskaitų faktūrų išrašymo, išsiuntimo ir saugojimo taisyklės“ <a href="http://www3.lrs.lt/pls/inter3/dokpaieska.showdoc_l?p_id=358040" target="_blank">VA-80</a>. </text> </index> </dataroot>Generated XML:
<?xml version="1.0" encoding="utf-8"?> <dataroot> <index> <key>global_header_country_name</key> <text> </text> </index> <index> <key>index_new_information_box_sub_title_text1</key> <text> </text> </index> <index> <key>recipients_page_description</key> <text> </text> </index> <index> <key>index_new_information_box_sub_title_text2</key> <text> </text> </index> </dataroot>So as you can see everything stayd at theis places, only <text> </text> are empyt. This is the place where i need to put transladet text from Rich Text Editor to XML via DataGrid - update command.
I have data grid, it looks like this:
<asp:DataGrid ID="ItemsGrid" runat="server" AllowPaging="True" OnUpdateCommand="ItemsGrid_UpdateCommand" OnEditCommand="ItemsGrid_EditCommand" OnCancelCommand="ItemsGrid_CancelCommand" AllowCustomPaging="True" AutoGenerateColumns="False" > <Columns> <asp:EditCommandColumn EditText="Edit" CancelText="Cancel" UpdateText="Update" /> <asp:TemplateColumn ItemStyle-Width="435"> <ItemTemplate> <asp:Literal runat="server" ID="ItemsGrid_raktas" Text='<%# Eval("key")%>'></asp:Literal> </ItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn ItemStyle-Width="435"> <ItemTemplate> <asp:Literal runat="server" ID="ItemsGrid_veciamas" Text='<%# Eval("text_source")%>'></asp:Literal> </ItemTemplate> <ItemStyle Width="435px"></ItemStyle> </asp:TemplateColumn> <asp:TemplateColumn> </asp:TemplateColumn> <asp:TemplateColumn ItemStyle-Width="565"> <ItemTemplate> <asp:Literal runat="server" ID="ItemsGrid_isverstas_Pasivus" Text='<%# Eval("text_destination") %>'></asp:Literal> </ItemTemplate> <EditItemTemplate> <FTB:FreeTextBox ID="tvarkykle" Text='<%# Eval("text_destination") %>' runat="server"> </FTB:FreeTextBox> </EditItemTemplate> <ItemStyle Width="565px"></ItemStyle> </asp:TemplateColumn> </Columns> <PagerStyle Mode="NumericPages" /> </asp:DataGrid>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 or provide some example ?
Probably it will be an easy one, but I`am just a beginner at asp .net
Regards!
amit.jain
Star
11225 Points
1815 Posts
Re: Update XML entries in XML template via datagrid update command handler
Mar 16, 2012 12:35 PM|LINK
Please refer Insert Edit Update GridView With XML Data
amiT jaiN
ASP.NET C# VB Articles And Code Examples
Daniil T.
Member
46 Points
32 Posts
Re: Update XML entries in XML template via datagrid update command handler
Mar 16, 2012 02:07 PM|LINK
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.
Daniil T.
Member
46 Points
32 Posts
Re: Update XML entries in XML template via datagrid update command handler
Mar 17, 2012 12:17 AM|LINK
So i found the solution for my issue.
protected void ItemsGrid_UpdateCommand(Object sender, DataGridCommandEventArgs e) { XmlDocument saltinis = new XmlDocument(); saltinis.Load(this.KeliasVerciamasXML); // Prideda elementus. XmlNodeList list = saltinis.GetElementsByTagName("index"); foreach (XmlNode Item in list) { if (Item.ChildNodes[0].InnerText == ((Literal)e.Item.Cells[1].FindControl("ItemsGrid_raktas")).Text) { Item.ChildNodes[1].InnerText = ((FreeTextBox)e.Item.Cells[4].FindControl("tvarkykle")).Text; } } XmlTextWriter writer = new XmlTextWriter(this.KeliasIsverstasXML, Encoding.UTF8); writer.Formatting = Formatting.Indented; saltinis.Save(writer); writer.Close(); ItemsGrid.EditItemIndex = -1; this.bindGrid(); }