Click here to Skip to main content
15,902,299 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
From poster tool i got the values from DB as xml tags how could i display in the form through gridview in front end????

TestService.Service wsTestService = new TestService.Service(); // form connected to webservice
XmlDocument document = new XmlDocument();
System.Xml.XmlNode newNode;
newNode = wsTestService.GetDataFromDB();
DataSet ds = new DataSet();
byte[] buf = System.Text.ASCIIEncoding.ASCII.GetBytes(newNode.OuterXml);
System.IO.MemoryStream ms = new System.IO.MemoryStream(buf);
ds.ReadXml(ms);
dataGridView1.DataSource = ds.Tables[0];
//dataGridView1.DataBind();
string Msg = string.Empty;
int Suc;
string Role = "student";
wsTestService.FACULTIES_ONLINE( Role ,out document, out Msg, out Suc); // document is xml document how could i call it??
Posted
Comments
Sergey Alexandrovich Kryukov 23-Apr-13 1:11am    
What do you mean by "calling a document"?
—SA
riodejenris14 23-Apr-13 1:13am    
how should i define the document as a gridview display inside the service parameters.

1 solution

Display as XmlNode Node(object)

DataTable dt = new DataTable();
dt.Columns.Add("FirstName", typeof(string));
dt.Columns.Add("LastName", typeof(string));
dt.Columns.Add("UserName", typeof(string));
dt.Columns.Add("Role", typeof(string));
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(Server.MapPath("SampleXML.xml"));
XmlNodeList nodeList = xmldoc.SelectNodes("/users/user");
foreach (XmlNode node in nodeList)
{
DataRow dtrow = dt.NewRow();
dtrow["FirstName"] = node["FirstName"].InnerText;
dtrow["LastName"] = node["LastName"].InnerText;
dtrow["UserName"] = node["UserName"].InnerText;
dtrow["Role"] = node["Job"]["Role"].InnerText;
dt.Rows.Add(dtrow);
}
gvDetails.DataSource = dt;
 
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