Wednesday, December 2, 2009

Gridview operations

Default.aspx


OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating" OnRowCancelingEdit="GridView1_RowCancelingEdit"
OnRowDeleting="GridView1_RowDeleting">





































Default.aspx.cs

using System;
using System.Data;
using System.Configuration;
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 System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
bindData();
}
private void bindData()
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ToString());
SqlCommand cmd = new SqlCommand("select id,name from employee", con);
SqlDataReader dr;
con.Open();
dr = cmd.ExecuteReader();
GridView1.DataSource = dr;
GridView1.DataBind();

}

protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
bindData();
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
if (e.RowIndex != -1)
{
int id = (int)GridView1.DataKeys[e.RowIndex].Value;
TextBox txt1 = (TextBox)GridView1.Rows[e.RowIndex].Cells[1].Controls[0];
string str1 = txt1.Text;


using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ToString()))
{
string sql = "UPDATE employee " + "SET name='" + str1 + "' " + "WHERE id= " + GridView1.DataKeys[e.RowIndex].Value;

SqlCommand cmd = new SqlCommand(sql, con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}

GridView1.EditIndex = -1;
bindData();

}
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
bindData();
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{

int id = (int)GridView1.DataKeys[e.RowIndex].Value;
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ToString()))
{

string sql = "Delete From employee Where id=@id";

con.Open();
SqlCommand cmd = new SqlCommand(sql, con);
cmd.Parameters.AddWithValue("@id", id);
cmd.ExecuteNonQuery();
con.Close();
bindData();
}


}
}


Friday, November 20, 2009

webpart searching for List items using Textbox and Botton

<em><code>
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;


namespace samplewebpart
{
public class Serach : WebPart
{
TextBox txt1 = new TextBox();
protected override void CreateChildControls()
{

txt1.ID = "txt1";
this.Controls.Add(txt1);
Button btn1 = new Button();
btn1.ID = "btn1";
btn1.Click += new EventHandler(btn1_Click);
this.Controls.Add(btn1);





}

protected void btn1_Click(object sender, EventArgs e)
{
using (SPSite oSite = new SPSite("http://server1:1234/sites/sample/default.aspx"))
{
using (SPWeb oWeb = oSite.OpenWeb())
{

SPList oList = oWeb.Lists["TaskList"];
SPQuery query = new SPQuery();

query.Query = "<Where>"
+"<Contains>"
+ "<FieldRef Name='Developer' />"
+ "<Value Type='Text'>"
+ txt1.Text
+ "</Value>"
+ "</Contains>"
+ "</Where>";
SPListItemCollection items = oList.GetItems(query);
GridView GridView1 = new GridView();
GridView1.DataSource = items.GetDataTable();
GridView1.DataBind();
this.Controls.Add(GridView1);

}
}

}
}
}
</code>.</em>

Tuesday, May 12, 2009

SharePoint interview questions

Sections
• MOSS

1. What is sharePoint?
2. What are the differences between SharePoint 2003 and 2007?
3. Can you explain briefly about the new features of SharePoint 2007?
4. What is the MOSS?
5. Can you explain content management system?
6. What is the different between site and web?
7. Can you write code for creating a site?
8. What is the context?
9. Is it possible to change the port number for SharePoint site?

• Site collection

10. How to create site collection?
11. How to delete a site collection?
12. How to take the backup of a site collection?
13. How to restore a site collection?

• SharePoint Administration

14. How to configure in coming and out going email service?
15. What is the active directory?
16. How to create a user profile?
17. How to import user profiles from active directory?
18. How to create a new user in SharePoint 2007?
19. How to provide group permissions?
20. How to delete permissions?
21. How to change the user permissions?
22. Can you explain the different types of permissions available in SharePoint 2007?

• SharePoint customization

23. What is the document library?
24. What are the new features for document library?
25. Can you explain major and miner version of document library?
26. Can you explain of check in check out process for document library?
27. How to update the doc file used by others?
28. What is the form library?
29. What is the picture library?
30. What are the disadvantages of document library?
31. How to manage the permissions for document library?
32. Can you explain the process of custom work flow for assigning a document for a user?
33. What are the steps involved in deleting document library?
34. Can you write the code for creating updating deleting for document library?
35. What is the wiki page?
36. What is the blog?
37. What is the discussion board?
38. What are the default custom lists for SharePoint 2003?
39. What are the default custom lists for SharePoint 2007?
• List
40. What is the list?
41. Can you explain the custom list?
42. How to import and export the list items?
43. How to create and delete and modify a list?
44. How to create a task list?
45. How to create a project task?
46. How to create a calendar task?
47. Can you write the code to create, insert, update and delete list?
48. How to provide permissions for a list?
49. How to add existing columns to the custom list?
50. What is the advantages and disadvantages of list in sharePoint 2007?

• views
51. What is the view?
52. How many types of views available in SharePoint 2007?
53. How to create a view for list?
54. How to create a view for document library?
55. Can you explain how to hide the columns for a list using view?
56. Can you explain how to add conditions view for the specific columns?
57. Can you explain how to create section view for the specific items?
58. What is the standard view?
59. What is the calendar view?
60. What is the datasheet view?
61. What is the Gantt view?
62. What is the access view?
63. Can you write steps to change a company log in SharePoint 2007?
64. How to change the order for the quick launch items?
65. How to change look and feel for a list?
66. What are the different types of custom lists?
67. What is the content type?
68. Can you explain the process of content type?
69. What is the site column?
70. How to create a site column?
71. If sub site column modified will it affect the root site column?
72. Can you write the source code for a site column?
73. What is the meeting workspace?
74. What are the types of meeting workspace?
75. What is the survey?
76. What are the site and workspaces?
77. How to create the site themes?
78. How to enable a tree view?
79. How to enable a quick launch?
80. How to create site template?
81. How to create the list template?
• CAML
82. What is the CAML?
83. Can you write a sample CAML query?
84. How to manipulate the list using CAML builder?
• BDC
85. Can you explain BDC?
86. Can you explain connection steps using BDC?
• web part
87. What is the web part?
88. Can you write steps to create the custom web part?
89. What is connected web part?
90. Can you write the Ajax code for web part?
91. What is the web part zone?
92. What is the web part manager?
93. Which events to add controls in web part?
94. How to debug a web part?
95. Suppose I got an error in web part how to handle it?
96. How to install web part into the production server?
97. What is signin?
98. How to publish a web part?
99. How to give permissions to web part?
100. What is the smart part?
101. What is my site?
102. What is the personalization?
103. What is the safe control?
104. What is the RSS?
• Object model
105. What is the base class library for SharePoint 2007?
106. Can you explain object model?
• events
107. Explain the events?
108. What are the events for the list and library?
109. Can you write the code for list event?

• SharePoint designer
110. What is the SharePoint designer?
• features
111. What are the SharePoint features?
112. How to install active, deactivate and delete feature?
113. What is the solution package?
114. How to create a batch file?
• workflows
115. What is the workflow?
116. Difference between state workflow and machine workflow?
117. How to create a custom workflow for a specific task?
118. Can you explain the process of a workflow?
119. Is it possible to create the workflow using SharePoint designer?
120. How to handle exceptions in the work flow?
121. Can you draw a workflow for a simple task?
122. What are the methods to run a workflow?
123. How to call the external methods in workflow?
124. How to create synchronous and asynchronous tasks in workflow?
125. How to create parallel conditions in workflow?

Friday, March 27, 2009

ASP.NET and C# interview questions top links

http://blogs.crsw.com/mark/articles/254.aspx
http://www.coolinterview.com/type.asp?iType=42
http://www.dotnetuncle.com/Aspnet/aspnet_questions.aspx
http://www.thinkinterview.com/interview-questions/t1/asp-net-controls.aspx
http://www.dotnetquestion.info/dot_net/asp_net.php

CAML QUERY for sharepoint

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
namespace CamlQuery
{
class CamlQuery
{
static void Main(string[] args)
{
"string StrQuery ="";
SPSite site = new SPSite(“site”);
SPWeb testWeb = site.AllWebs[“web”];
SPList bdcList = testWeb.Lists[“list”];
SPQuery query = new SPQuery();
query.Query = StrQuery;
SPListItemCollection filteredItems =
bdcList.GetItems(query);
Console.WriteLine(“ available items”,
filteredItems.Count);
foreach (SPListItem item in filteredItems)
{
Console.WriteLine(“Found Order:”,
item[“Order”],
item[“Order: OrderName”]);
}

}
}
}

-Bharath

Add a GridView to a sharepoint webpart

using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;


namespace samplewebpart
{
public class GridControl : WebPart
{
protected override void CreateChildControls()
{

GridView grdview = new GridView();
SPWeb web = SPContext.Current.Web;
SPList list = web.Lists["mylist"];
grdview.DataSource = list.Items.GetDataTable();
grdview.DataBind();
this.Controls.Add(grdview);


}
}
}

-Bharath Boddu

Sharepoint List

Creating Sharepoint List using object model

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;

SPWeb mySite = SPContext.Current.Web;
SPListCollection lists = mySite.Lists;

string listTitle = "List Title";
string listDescription = "Lst Description";
string listType = "Announcements";

SPListTemplateType listTemplateType = new SPListTemplateType();

listTemplateType = SPListTemplateType.Announcements;
lists.Add(listTitle, listDescription, listTemplateType);

Delete Sharepoint List

SPWeb mySite = SPContext.Current.Web;
SPListCollection lists = mySite.Lists;

SPList list = lists["ListName"];
System.Guid listGuid = list.ID;

lists.Delete(listGuid);

Update Sharepoint List

SPWeb mySite = SPContext.Current.Web;
SPListItemCollection listItems = mySite.Lists["ListName"].Items;

SPListItem item = listItems.Add();

item["Title"] = "List Title";
item["First Name"] = "FirstName";
item["Last Name"] = "Last Name";
item["Address"] = "Address";

item.Update();
}



-Bharath Boddu

Saturday, March 14, 2009

Top Links on Sharepoint

http://www.sheltonblog.com/
This Blog contains videos,tutorials and lot of useful information on Sharepoint.

http://technet.microsoft.com/en-us/windowsserver/sharepoint/bb407286.aspx. It provides the information about how to deploy the custom templates within the organization.

http://www.codeguru.com/csharp/.net/net_asp/webforms/article.php/c12293/
This site contains information on webpart creation.

-Bharath Boddu