![]() |
|
|
#1 (permalink) |
|
Insane
Location: West Virginia
|
C# and dataGrid
Okay, I am doing a dataGrid that loads in an XML file and displays it on the screen by using the following...
Code:
private void loadButton_Click(object sender, System.EventArgs e)
{
mySet = LoadBooks( @"C:\Documents and Settings\Jay\Desktop\C#\pgm2\Books.xml" );
dataGrid.DataSource = mySet;
}
public DataSet LoadBooks( string strFileName )
{
DataSet loadSet = new DataSet();
loadSet.ReadXml( strFileName );
return loadSet;
}
Here's the method prototype that my add book button click will call: Code:
addBook( mySet, newTitle.Name, newAuthor.Name );
__________________
- Artsemis ~~~~~~~~~~~~~~~~~~~~ There are two keys to being the best: 1.) Never tell everything you know |
|
|
|
|
#3 (permalink) |
|
Crazy
|
What you want to do is create a new DataRow and add it to the DataSet and then rebind the DataSet to the DataGrid. Then when the user clicks "Save" then you update the XML file. Here's a link showing you how to do that
|
|
|
|
|
#4 (permalink) |
|
Insane
Location: West Virginia
|
I had done something similar to what you just posted twister, but I had a problem with my dataset having a duplicate table name inside. If I gave the new one a different name, it wouldn't add it to the same table, but create a new one in the grid.
I ended up finding a simple update method to call on my current table ![]() Thanks for the help guys.
__________________
- Artsemis ~~~~~~~~~~~~~~~~~~~~ There are two keys to being the best: 1.) Never tell everything you know |
|
|
| Tags |
| datagrid |
|
|