Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0 ASMX
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 22-Apr-13 20:00pm
Comments
Sergey Alexandrovich Kryukov at 23-Apr-13 1:11am
   
What do you mean by "calling a document"?
—SA
muhammed riyaaz at 23-Apr-13 1:13am
   
how should i define the document as a gridview display inside the service parameters.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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;
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 365
1 Sergey Alexandrovich Kryukov 319
2 CPallini 275
3 DamithSL 214
4 Maciej Los 185
0 OriginalGriff 5,455
1 DamithSL 4,457
2 Maciej Los 3,885
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,115


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 2 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100