Prasad Bolla's SharePoint Blog

Click Here to go through the Interesting posts within my Blog.

Click Here to go through the new posts in my blog.

Monday, November 28, 2011

Retrieving subsites under the topsite to a spgridview using SharePoint Default WebServices

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Webs;
using System.Xml;
public partial class Default11 : System.Web.UI.Page
{
DataSet dset = new DataSet();
//DataSet dset1 = new DataSet();
//DataTable dt = new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//Prasad.Lists listService = new Prasad.Lists();
Webs.Webs web_Service = new Webs.Webs();
web_Service.UseDefaultCredentials=true;
web_Service.Url = "http://vlnrm:100/_vti_bin/webs.asmx";
System.Xml.XmlNode nodeListItems = web_Service.GetWebCollection();
DataSet ds = getData(nodeListItems);
DataTable dt = ds.Tables["Web"];
GridView1.DataSource = dt;
GridView1.DataBind();
Response.Write(""); Response.Write(""); Response.Write(""); Response.Write(""); for (int i = 0; i < dt.Rows.Count; i++) { string strTitle = dt.Rows[i]["Title"].ToString(); string strUrl = dt.Rows[i]["Url"].ToString(); Response.Write(""); Response.Write(""); Response.Write(""); } Response.Write("
");
Response.Write("Subsites List");
Response.Write("
");
Response.Write(""+strTitle+"");
Response.Write("
");
}
}
public DataSet getData(XmlNode xmlnodeinput)
{
if (xmlnodeinput != null)
{
XmlTextReader xtr = new XmlTextReader(xmlnodeinput.OuterXml, XmlNodeType.Element, null);
//dataset = new DataSet();
dset.ReadXml(xtr);
}
return dset;
}
/*public DataSet getData1(XmlNode xmlnodeinput)
{
if (xmlnodeinput != null)
{
XmlTextReader xtr = new XmlTextReader(xmlnodeinput.OuterXml, XmlNodeType.Element, null);
//dataset = new DataSet();
dset1.ReadXml(xtr);
}
return dset1;
}*/

}

No comments:

Post a Comment