473,406 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

From ListView to DataSet

Hello everyone !

As you can see I am new to this. It is also my first post! I have a
visual c# pocket pc form with a listview in it. The listview has one
column at the moment and it is populated by using a textbox and a
button. I am trying to save to contents of the listview to an Xml file.

I have the following code and the debugger gives me no errors, but when
I am trying to save on the pocket pc or the emulator I get
InvalidCastException. I guess that the problem is when I convert the
listview to the dataset but I can’t figure it out. I would really
appreciate your input.

DataSet data = new DataSet();
DataGrid dg = new DataGrid();
dg.DataSource = listView1.Items;
data = (DataSet) dg.DataSource;

and then save the data like:

Writer = new XmlTextWriter(DataFile,
System.Text.Encoding.Unicode);
data.WriteXml(Writer,XmlWriteMode.WriteSchema);
Writer.Close();

There is a lot of info on how to populate a datagrid or listview from an
xml using a dataset. But how can I do the opposite ?? The datagrid does
take the data from the list but the conversion to dataset gives errors
(InvalidCastException)..
Thanks in advance !

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #1
0 2962

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: ExDelphi | last post by:
Hi All I am fairly new to VB.Net, and have gotten stuck with an invoicing application. My database (Access 2000 / 2003) is used to store records of our products, customers, suppliers etc. The user...
0
by: Bom | last post by:
Hi, I bound a dataset to a listview (I used example of Lothka). I have also a button delete. When I select a row in the listview and I push delete-button I can delete the row in the dataset as...
4
by: microsoft.news.com | last post by:
how can I get the values from my dataset to populate a form? I have the dataset in XML and I want to read it and get the data values out of it to populate my form. I want to show them all and not...
3
by: alan | last post by:
What I would like to do is like that, a ListView data binding with a dataset which list all records of a table( for example the table list all the information of a student student_id, name,...
4
by: Lasse Eskildsen | last post by:
Hi, Is there an easy way to load the content of a dataset into a listview with a few columns? Thanks! -- Lasse
11
by: Kay | last post by:
Hi all, I have populated a dataset with several tables, say - Roster, Agent and few more . The dataset is used to populated a listview with some shift info.. I think I'm sucessfully created a...
1
by: Mike | last post by:
Hi! I am wandering what the fastest way to transfer a large dataset with 1 table to a ListView ? Can databinding speed things up ? Some code sample are greatly appreciated if binding can make...
1
by: Monty M. | last post by:
Does anyone know how to perform two way data binding between a combo box and a listview. The listview is bound to a dataset table in code: Binding Bind = new Binding(); DataTable dt;...
4
by: IfThenElse | last post by:
Hi, Is there an easy way now in 2005? Need full example url etc.. Thank you,
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.