binding - Adding/Deleting items from a databound listbox -
I have recently put an XML file in a listbox, now I want to add or remove items from that listbox I want to type the function. The following error occurred when trying to listbox.items.add or listbox.items.insert:
Instead of accessing and modifying elements of Controls.ITSOSOO elements.
I googled it and said it instead to work on 'model',
But I do not have any clue how to do this, how do I get more data from datasets Can I add or remove? I hate adding XML elements and values to the original and then updating the file as a data source ...
How about loading XML in a dataset and then restricting and rebounding the dataset?
Instead of using the XML file and binding it in the listbox, try it: ()
string myXMLfile = "C: \\ MySchema.xml"; Dataset ds = new dataset (); Try {// reads file and data dataset in ds.ReadXml (myXMLfile); // Set the dataset of the list set to // set / Note that if you have a complex XML you need to set it in one of the datasets in Dataset so that you can get the list you want List1.DataSource = Ds; ListBox1.DataBind (); } Hold (exception before) {// handle error}
Let's get you XML simple instead. If you do not see the name of your table (your XML) then Dataset is new customer customer = DTTables ["Customer"] .NewRow (); NewCustomersRow ["customerID"] = "ALFKI"; NewCustomersRow ["CompanyName"] = "Alfreds Footkirts"; DataSet1.Tables ["Customers"] Rows.Add (newCustomersRow).
Here is an XML example, which should work with the above:
& lt; Data & gt; & Lt; Customers & gt; & Lt; Customers & gt; & Lt; CustomerID & gt; 123 & lt; / CustomerID & gt; & Lt; CompanyName & gt; Name & lt; / CompanyName & gt; & Lt; / Customer & gt; & Lt; / Customers & gt; & Lt; / Data & gt;
I have not tried compiling or running it, but you should get general idea and convert it to my code.
Comments
Post a Comment