Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
i m fairly new to the xml. so please help me regarding filling data in datagridview from a xml file.
here is my xml example
XML
<Table>
  <sentmail>
    <to>xxxxx</to>
    <text>hello world</text>
    <time> 11/28/2012 <time />
    <from> john <from />
  </sentmail>
  <sentmail>
    <to>xxxxx</to>
    <text>hello john </text>
    <time> 11/28/2012 <time />
    <from> charlie <from />
  </sentmail>

ok. now i can put this xml in datagridview with this code:
C#
dataset ds=new dataset();
XmlReader xmlFile;
xmlFile = XmlReader.Create(@"D:\New Folder\New Folder\sent_mail.xml", new XmlReaderSettings());
ds.ReadXml(xmlFile);
dataGridView1.DataSource = ds.Tables[0];

it works fine.
but i don't want to fill "from" element in datagridview. how can i escape this element from being fetched.
Posted
Updated 29-Nov-12 17:36pm
v2

1 solution

2 Options, remove the From element from the data set (delete the column from ds.tables[0].columns["from"])

or

After the data is bound to the datagridview set the DGV column width to 0 (dgv.columns[3].width = 0)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900