<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SasiTreeViewUserControl.ascx.cs" Inherits="May9thVisualWebParts.SasiTreeView.SasiTreeViewUserControl" %>
<asp:TreeView ID="siteStructure" runat="server">
</asp:TreeView>
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
namespace May9thVisualWebParts.SasiTreeView
{
public partial class SasiTreeViewUserControl : UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
SPWeb thisWeb = SPContext.Current.Web;
TreeNode node = new TreeNode(thisWeb.Title, null, null, thisWeb.Url, "_self");
siteStructure.Nodes.Add(node);
TreeNode ParentNode = node;
foreach (SPList list in thisWeb.Lists)
{
if (!list.Hidden)
{
node = new TreeNode(list.Title, null, null, list.DefaultViewUrl, "_self");
ParentNode.ChildNodes.Add(node);
}
}
foreach (SPWeb childWeb in thisWeb.Webs)
{
AddWebs(childWeb, ParentNode);
childWeb.Dispose();
}
siteStructure.CollapseAll();
}
void AddWebs(SPWeb web, TreeNode ParentNode)
{
TreeNode node = new TreeNode(web.Title, null, null, web.Url, "_self");
ParentNode.ChildNodes.Add(node);
ParentNode = node;
foreach (SPList list in web.Lists)
{
node = new TreeNode(list.Title, null, null, list.DefaultViewUrl, "_self");
ParentNode.ChildNodes.Add(node);
}
foreach (SPWeb childWeb in web.Webs)
{
AddWebs(childWeb, ParentNode);
childWeb.Dispose();
}
}
}
}
-----
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
using System.Data;
namespace May9thVisualWebParts.DeepakGV
{
public partial class DeepakGVUserControl : UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=WSS_Content_9997;Data Source=BALDH01-NB\\SQL2008");
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter("Select top 10 * from alllists", con);
da.Fill(ds, "allLists");
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
}
}
}
No comments:
Post a Comment