Getting Gridview to read an XML file

  • Thread starter Thread starter hal
  • Start date Start date
H

hal

Hello All,
I have a windows form with a gridview control and i'm trying to get the
gridview to read the entire XML file. Anyone have any ideas on how to
do this? Below is some code so you can see what I'm trying to do.

private void btnBuildList_Click(object sender, EventArgs e)
{
string getCustomer = GetCustomer(txtLastName.Text,
txtFirstName.Text, txtUserID.Text);
Class1 ds = new Class1();
System.IO.StringReader s = new
System.IO.StringReader(getCustomer);

ds.ReadXml(s);

usersGridView.DataSource = ds;
usersGridView.DataMember = ds.DataTable.ToString();
}

Thanks
 
try this

//getCustomer must be XML
string getCustomer = GetCustomer(txtLastName.Text,
txtFirstName.Text, txtUserID.Text);

DataSet ds = new DataSet();

ds.ReadXml(s);

usersGridView.DataSource = ds;
usersGridView.DataMember = ds.Tables[0].Name;
//or
usersGridView.DataSource = ds.Tables[0];


hope this helps
Galin Iliev[MCSD.NET]
www.galcho.com
 
Back
Top