TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Leone Damas
NA
13
10.4k
Update to XML using DataGridView (LINQ)
Feb 16 2011 3:20 PM
Hello,
I am stuck at the point of updating XML when cell value changed in DataGridView.
I am using LINQ to XML approach. I am able to assign the query output using ToList() as Datasource of DataGridView.
On Cell value changed or Row added/deleted, I tried to cast the Datasource to DataTable & DataSet, but failed on both attempts.
In what form can i get the DataGridView.DataSource, so that i can hit the update on the XML file?
Let me elaborate the situation,
var query = from e in empxmldoc.Descendants("emp")
where (string)e.Attribute("dept") == "dept01";
select new { Name = e.Value, Dept=e.Attribute("dept").Value, Salary=e.Attribute("sal").Value};
DataGridView1.DataSource = query.ToList();
Above illustrates how i am loading my xml data into DataGridView. [
Above is working, no issue with loading data into DataGridView
]
But, on cell value changed, row added events, I tried
1. DataTable dt = DataGridView1.DataSource;
2. DataSet ds = DataGridView1.DataSource;
3. DataTable dt = (DataTable)DataGridView1.DataSource;
4. DataSet ds = (DataSet)DataGridView1.DataSource;
But, cannot get the data into any of them.
Reply
Answers (
13
)
BulkInserts without SQLBulkCopy
How to checkNull values using Execute Scalar