Save checkboxlist values to xml using vb.net -


I have some checkboxes like this:

  & lt; Asp: checkbox list id = "g1" runat = "server" & gt; & Lt; ASP: ListItem Price = "Comunicações Unificadas" text = "Comunicações Unificadas - UCoIP" & gt; & Lt; / ASP: ListItem & gt; & Lt; ASP: List Itam Value = "Getawo Documentary" Text = "Getaa Documentary - iPortgage Doc" & gt; & Lt; / Asp: ListItem & gt; & Lt; Asp: ListItem value = "Gestão Conteudos Web" text = "Gestão de Conteudos Web" & gt; & Lt; / Asp: ListItem & gt; & Lt; Asp: ListItem Value = "Promosite Websites" text = "Promos of Websites" & gt; & Lt; / Asp: ListItem & gt; & Lt; Asp: ListItem value = "Consultation of services" text = "Consultation of services" & gt; & Lt; / Asp: ListItem & gt; & Lt; / ASP: CheckBoxList & gt; When submitting a form from  

they are included, I want to save all the selected values ​​in an XML file.

At the moment, if I select more than one value submit, in the XML file, I choose only for the first time, do not appear in other files.

I am saving them in the XML file:

Dynamic document new XmlDocument () doc.Load (LocalizacaoFicheiro)

  As a slow visitor XmlElement = doc.CreateElement ("Cliente") dim res1 as XmlElement = doc.CreateElement ("Resposta1") res1. InnerText = G1.SelectedValue.ToString visitor.AppendChild (res1) doc.DocumentElement.AppendChild (visitor) doc.Save (LocalizacaoFicheiro)  

I change the way that I save Need Data for XML, right? Text after "

CheckBoxList.SelectedValue is just one price, of course that's when you If you use that property, then you are getting only one value, it is designed to give you only the first selected value:

If more than one item is selected, then the following The value of the items selected with the indicator is returned.

Instead, use the CheckBoxList.Items to check the looping and ListItem.Selected property between them all; To see whether they have been chosen or not. (Or use the equivalent LINQ expression, whatever you want.)


Comments