Wednesday, February 20, 2008
Tab Control functionality in Html
http://www.thesug.org/blogs/kyles/Lists/Posts/Post.aspx?List=89c8858b%2D90d2%2D4750%2Da11a%2De599248e6c69&ID=8
Tuesday, February 19, 2008
Datagrid( with database retrieval ) as webpart sharepoint
I. Reference link
http://www.devx.com/dotnet/Article/26732/1954,
there u can download zip file and in that GetDataChildControl.cs
is taken and modified as follows
1. Use the STSDEV tool to creat a project.
2. Open the customwebpart1.cs and modify the page to look as follows:
namespace DbGridWebPart
{
[DefaultProperty("Text"),
ToolboxData("<{0}:GetData runat=server>{0}:GetData>"),
XmlRoot(Namespace = "WebParts")]
public class CustomWebPart1 : WebPart
{
private const string defaultConnection = "Server=server;database=pubs;Integrated Security=false;User Id=sa;Password=";
private string connectionString = defaultConnection;
[Browsable(true),
Category("Data"),
DefaultValue(defaultConnection),
WebPartStorage(Storage.Shared),
FriendlyName("Connection String"),
Description("Connection String")]
public string ConnectionString
{
get
{
return connectionString;
}
set
{
connectionString = value;
}
}
private const string defaultSQL = "SELECT TOP 2 au_lname, au_fname FROM Authors";
private string sqlString = defaultSQL;
[Browsable(true),
Category("Data"),
DefaultValue(defaultSQL),
WebPartStorage(Storage.Shared),
FriendlyName("SQL Command"),
Description("The SQL command, or stored procedure to execute")]
public string SQLString
{
get
{
return sqlString;
}
set
{
sqlString = value;
}
}
///
/// Constructor for GetDataChildControl
///
public CustomWebPart1()
{
try
{
}
catch (Exception excpt)
{
Label lbl = new Label();
lbl.Text = "An error occured : " + excpt.ToString();
Controls.Add(lbl);
}
}
private bool bDGAdded = false;
///
/// Render this Web Part to the output parameter specified.
///
/// The HTML writer to write out to
protected override void RenderWebPart(HtmlTextWriter output)
{
// If the data grid has not been added
if (!bDGAdded) AddDG();
base.RenderWebPart(output);
}
protected void AddDG()
{
System.Data.SqlClient.SqlConnection mySQLConnect = new SqlConnection(connectionString);
mySQLConnect.Open();
SqlCommand myCmd = new SqlCommand(sqlString, mySQLConnect);
System.Data.SqlClient.SqlDataAdapter myAdapter = new SqlDataAdapter(myCmd);
DataSet ds = new DataSet();
myAdapter.Fill(ds, "Test");
DataGrid dg = new DataGrid();
dg.DataSource = ds.Tables[0];
dg.DataBind();
Controls.Add(dg);
bDGAdded = true;
}
}
}
3. Then the rest are same as deployment to the server.
4. And if u want to change the query or server settings in sharepoint site, click the modify shared web part on the webpart menu and then point to Data setttings, there u can change those settings.
http://www.devx.com/dotnet/Article/26732/1954,
there u can download zip file and in that GetDataChildControl.cs
is taken and modified as follows
1. Use the STSDEV tool to creat a project.
2. Open the customwebpart1.cs and modify the page to look as follows:
using System.Data;
using System.Data.SqlClient;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.WebPartPages;
using System.ComponentModel;
using System.Data.SqlClient;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.WebPartPages;
using System.ComponentModel;
namespace DbGridWebPart
{
[DefaultProperty("Text"),
ToolboxData("<{0}:GetData runat=server>{0}:GetData>"),
XmlRoot(Namespace = "WebParts")]
public class CustomWebPart1 : WebPart
{
private const string defaultConnection = "Server=server;database=pubs;Integrated Security=false;User Id=sa;Password=";
private string connectionString = defaultConnection;
[Browsable(true),
Category("Data"),
DefaultValue(defaultConnection),
WebPartStorage(Storage.Shared),
FriendlyName("Connection String"),
Description("Connection String")]
public string ConnectionString
{
get
{
return connectionString;
}
set
{
connectionString = value;
}
}
private const string defaultSQL = "SELECT TOP 2 au_lname, au_fname FROM Authors";
private string sqlString = defaultSQL;
[Browsable(true),
Category("Data"),
DefaultValue(defaultSQL),
WebPartStorage(Storage.Shared),
FriendlyName("SQL Command"),
Description("The SQL command, or stored procedure to execute")]
public string SQLString
{
get
{
return sqlString;
}
set
{
sqlString = value;
}
}
///
/// Constructor for GetDataChildControl
///
public CustomWebPart1()
{
try
{
}
catch (Exception excpt)
{
Label lbl = new Label();
lbl.Text = "An error occured : " + excpt.ToString();
Controls.Add(lbl);
}
}
private bool bDGAdded = false;
///
/// Render this Web Part to the output parameter specified.
///
/// The HTML writer to write out to
protected override void RenderWebPart(HtmlTextWriter output)
{
// If the data grid has not been added
if (!bDGAdded) AddDG();
base.RenderWebPart(output);
}
protected void AddDG()
{
System.Data.SqlClient.SqlConnection mySQLConnect = new SqlConnection(connectionString);
mySQLConnect.Open();
SqlCommand myCmd = new SqlCommand(sqlString, mySQLConnect);
System.Data.SqlClient.SqlDataAdapter myAdapter = new SqlDataAdapter(myCmd);
DataSet ds = new DataSet();
myAdapter.Fill(ds, "Test");
DataGrid dg = new DataGrid();
dg.DataSource = ds.Tables[0];
dg.DataBind();
Controls.Add(dg);
bDGAdded = true;
}
}
}
3. Then the rest are same as deployment to the server.
4. And if u want to change the query or server settings in sharepoint site, click the modify shared web part on the webpart menu and then point to Data setttings, there u can change those settings.
Wednesday, February 13, 2008
Creating Templates for sharepoint sites using Sharepoint solution Generator tool
References
1. http://weblogs.asp.net/soever/archive/2006/11/11/SharePoint-Solution-Generator-_2D00_-part-1_3A00_-create-a-site-definition-from-an-existing-site.aspx
2. http://www.microsoft.com/downloads/details.aspx?FamilyId=C1039E13-94DA-4D7D-8CAE-3B96FA5A4045&displaylang=en
1. http://weblogs.asp.net/soever/archive/2006/11/11/SharePoint-Solution-Generator-_2D00_-part-1_3A00_-create-a-site-definition-from-an-existing-site.aspx
2. http://www.microsoft.com/downloads/details.aspx?FamilyId=C1039E13-94DA-4D7D-8CAE-3B96FA5A4045&displaylang=en
Creating and Deploying Webparts to Sharepoint site using STSDEV tool
1. Download stsdev tool from the Net.
(do it in your system)
2. Open Visual Studio 2005, point to Tools menu, and then External Tools...
and add name of the tool as stsdev and in the next tab, locate the stsdev.exe file and click ok.
3. Now click on the Tools->stsdev
4. Give Solution Name, then select parent directory for ex, f:\framework\examples, and in the next
tab such as signing key, f:\framework\examples\sn.snk and select the solution type as web part solution(C# Assembly) and click the create solution button.
5. Open the Project .sln file and all the files will be created by default. Open Customwebpart1.cs and Customwebpart2.cs and change the codings whatever the control you need to add.
(do it in sharepoint server)
6. Upload project to sharepoint server and open the .sln file. select debugbuild and click build, then
debugdeploy and click build.
7. Now open a new site and point to site actions -> site settings page.
8. Under Galleries section, click webpart and then click new, select the newly added webparts and upload it. so that new webparts is displayed.
9. Now you create a blank web part page and click on it. you are willing to add the newly added webpart
Reference Links:
(do it in your system)
2. Open Visual Studio 2005, point to Tools menu, and then External Tools...
and add name of the tool as stsdev and in the next tab, locate the stsdev.exe file and click ok.
3. Now click on the Tools->stsdev
4. Give Solution Name, then select parent directory for ex, f:\framework\examples, and in the next
tab such as signing key, f:\framework\examples\sn.snk and select the solution type as web part solution(C# Assembly) and click the create solution button.
5. Open the Project .sln file and all the files will be created by default. Open Customwebpart1.cs and Customwebpart2.cs and change the codings whatever the control you need to add.
(do it in sharepoint server)
6. Upload project to sharepoint server and open the .sln file. select debugbuild and click build, then
debugdeploy and click build.
7. Now open a new site and point to site actions -> site settings page.
8. Under Galleries section, click webpart and then click new, select the newly added webparts and upload it. so that new webparts is displayed.
9. Now you create a blank web part page and click on it. you are willing to add the newly added webpart
Reference Links:
Subscribe to:
Comments (Atom)
