By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,771 Members | 1,741 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,771 IT Pros & Developers. It's quick & easy.

Getting Gridview to read an XML file

P: n/a
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

Jun 14 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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

hal wrote:
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


Jun 14 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.