Thursday, June 26, 2008
Saturday, June 7, 2008
Add a SharePoint security group through code
SPWeb web = SPContext.Current.Web
web.SiteGroups.Add("MySecurityGroup", web.CurrentUser, web.CurrentUser, "My own custom security group");
SPGroup myGroup = web.SiteGroups["MySecurityGroup"];
SPRoleAssignment roleAssignment = new SPRoleAssignment(myGroup);
SPRoleDefinition roleDefinition = site.RoleDefinition["Full Control"];
roleAssignment.RoleDefinitionBindings.Add(roleDefinition);
web.RoleAssignments.Add(roleAssignment);
web.SiteGroups.Add("MySecurityGroup", web.CurrentUser, web.CurrentUser, "My own custom security group");
SPGroup myGroup = web.SiteGroups["MySecurityGroup"];
SPRoleAssignment roleAssignment = new SPRoleAssignment(myGroup);
SPRoleDefinition roleDefinition = site.RoleDefinition["Full Control"];
roleAssignment.RoleDefinitionBindings.Add(roleDefinition);
web.RoleAssignments.Add(roleAssignment);
Sunday, June 1, 2008
SPGridView - Deleting a row
The signature of the Deleting event handler when u select the Delete link button :
private void gridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int rowIndex = e.RowIndex; // This gets you the row that u just clicked on the Delete button
GridViewRow row = gridView.Rows[rowIndex];
//To reference a particular column in that row, you can:
row.Cell[0].Text
// Where 0 is the reference to the first column in row.
//Since this gridview is binded to the datatable, just remove the row from the datatable and re bind to the grid view.
}
private void gridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int rowIndex = e.RowIndex; // This gets you the row that u just clicked on the Delete button
GridViewRow row = gridView.Rows[rowIndex];
//To reference a particular column in that row, you can:
row.Cell[0].Text
// Where 0 is the reference to the first column in row.
//Since this gridview is binded to the datatable, just remove the row from the datatable and re bind to the grid view.
}
Labels:
delete,
delete a row,
Deleting a row,
grid view,
SPGridView
SPGridView - Using a data table as the datasource
Loading a SPList of items into a datatable, then binding this datatable to the SPGridView.
SPGridView gridView = new SPGridView();
DataTable dt = new DataTable();
dt = new DataTable();
dt.Columns.Add("First Name");
dt.Columns.Add("Last Name");
dt.Columns.Add("Street Address");
dt.Columns.Add("Email Address");
foreach(SPListItem item in {insert SPList}.Items)
{
DataRow dr = dt.NewRow();
dr["First Name"] = item["First Name];
dr["Last Name"] = item["Last Name"];
dr["Street Address"] = item["Street Address"];
dr["Email Address"] = itemS["Email Address"];
dt.Rows.Add(dr);
}
gridView.DataSource = dt;
gridView.DataBind();
SPGridView gridView = new SPGridView();
DataTable dt = new DataTable();
dt = new DataTable();
dt.Columns.Add("First Name");
dt.Columns.Add("Last Name");
dt.Columns.Add("Street Address");
dt.Columns.Add("Email Address");
foreach(SPListItem item in {insert SPList}.Items)
{
DataRow dr = dt.NewRow();
dr["First Name"] = item["First Name];
dr["Last Name"] = item["Last Name"];
dr["Street Address"] = item["Street Address"];
dr["Email Address"] = itemS["Email Address"];
dt.Rows.Add(dr);
}
gridView.DataSource = dt;
gridView.DataBind();
Labels:
databinding,
datarow,
datatable,
gridview,
SPGridView
Attach an event handler to a specific list using a feature
Declare a normal feature with reference to a elements.xml

In this elements.xml, we have a and attribute. Ths ListTemplateId is necessary to define which list this event handler will be attached to.

In this elements.xml, we have a
Deploy a new List instance using a Feature
This feature is used to provision an instance of the Links list to a specified site on deployment via STSADM.

The {Guid} in this elements file is : 00BFEA71-2062-426C-90BF-714C59600103

The {Guid} in this elements file is : 00BFEA71-2062-426C-90BF-714C59600103
Deploy an Event Handler using a Feature for SPFeatureReceiver
To deploy a event handler that will be activated when the feature is activated (i.e. overriding the following methods : FeatureInstalled, FeatureUninstalling, FeatureActivated, FeatureDeactivating et .. what ever comes under the parent inheiritance from SPFeatureReceiver.
Put the Event Handler .dll into the Assembly (GAC) then create a feature to install it:

Put the Event Handler .dll into the Assembly (GAC) then create a feature to install it:

Subscribe to:
Comments (Atom)
.jpg)
