<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Techyard's Blog</title>
	<atom:link href="http://techyard.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://techyard.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Sat, 07 May 2011 21:52:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='techyard.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Techyard's Blog</title>
		<link>http://techyard.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://techyard.wordpress.com/osd.xml" title="Techyard&#039;s Blog" />
	<atom:link rel='hub' href='http://techyard.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Working with sharepoint large lists</title>
		<link>http://techyard.wordpress.com/2009/10/07/working-with-sharepoint-large-lists/</link>
		<comments>http://techyard.wordpress.com/2009/10/07/working-with-sharepoint-large-lists/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 15:27:45 +0000</pubDate>
		<dc:creator>techyard</dc:creator>
				<category><![CDATA[Sharepoint/Wss 3.0]]></category>
		<category><![CDATA[Sql Server]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[CAML]]></category>
		<category><![CDATA[Large lists]]></category>
		<category><![CDATA[Sharepoint]]></category>
		<category><![CDATA[Sharepoint Large Lists]]></category>
		<category><![CDATA[splistitem]]></category>
		<category><![CDATA[SPListItemCollection]]></category>
		<category><![CDATA[SPQuery]]></category>
		<category><![CDATA[WSS 3.0]]></category>

		<guid isPermaLink="false">http://techyard.wordpress.com/?p=64</guid>
		<description><![CDATA[Please visit this : Samsung Service Galaxy S In a recent project, I had to get some information from the last sharepoint listitems inserted. I used foreach. Of course it is a bad idea. When the list grew (thousand of listitems)&#8230;the program worked as fast as a drunken turtle. Ok&#8230; As I was saying the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techyard.wordpress.com&amp;blog=6899255&amp;post=64&amp;subd=techyard&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Please visit this :<strong><a title="Samsung Galaxy S" href="http://samsunggalaxysi900.wordpress.com/2011/05/07/why-not-samsung-galaxy-s-i9000-or-any-other-samsung-phone/"> Samsung Service Galaxy S</a></strong></p>
<p>In a recent project, I had to get some information from the last sharepoint listitems inserted. I used foreach. Of course it is a bad idea. When the list grew (thousand of <strong>listitems</strong>)&#8230;the program worked as fast as a drunken turtle. Ok&#8230; As I was saying the data I needed was from the last x <strong>items</strong> inserted. So I replaced the foreach with a simple for:<br />
count=10; (the last 10 items inserted)<br />
for (int i = o<strong>List.Items.Count</strong> &#8211; count; i &lt; oList.Items.Count; i++)</p>
<p>I ran the program and saw that the improvement was not what I expected, so I made a testProject to measure the execution time, for the foreach block code and the code above (with the simple for);</p>
<p>DateTime startTime = DateTime.Now;</p>
<p>chunk of code (for or foreach iteration)</p>
<p>DateTime stopTime = DateTime.Now;<br />
TimeSpan duration = stopTime &#8211; startTime;</p>
<p>For <strong>large lists</strong> the foreach statement took forever. The for statement took from 5 to 30 seconds for 4000 list items.<br />
The odd part was that in the for statement as I said before, i iterated through the last 10 items.<br />
So for 10 items I waited some good seconds.<br />
I googled for the truth and I found this interesting <a href="http://www.docstoc.com/docs/12105826/Working-with-large-lists-in-Office---Office-Online-Home-Page">article</a>.</p>
<p>So I found out the <strong>SPQuery</strong> is one of the best ways to work with large lists.</p>
<p><strong>SPQuery</strong> <strong>query</strong> = new <strong>SPQuery</strong>(oList.Views[0]);<br />
<img class="aligncenter size-full wp-image-73" title="Comm" src="http://techyard.files.wordpress.com/2009/10/comm.jpg?w=450&#038;h=37" alt="Comm" width="450" height="37" /><br />
query.RowLimit = 10;<br />
SPListItemCollection filteredList = oList.GetItems(query);<br />
foreach (SPListItem item in filteredList)<br />
{<br />
Blabla;<br />
}</p>
<p>I ordered the list <strong>Descending</strong> by their ID so i got the most recent 10 list items.<br />
I measured the execution time. At the first run it took 800 milliseconds for 4000 list items. The next executions took only from 15 to 30 milliseconds.<br />
I would say&#8230;it is at least a good improvement;<br />
An easier way to create <strong>CAML</strong> queries is with <a href="http://www.u2u.be/Res/Tools/CamlQueryBuilder.aspx"> U2U CAML Query Builder</a><br />
I tried to use <strong>CAML</strong> query to get the max ID directly but I didn`t succeed. If someone reads this&#8230;:P and knows how please leave a reply.</p>
<p><a title="Commerce Server 2009" href="http://ronua.ro/CS/blogs/commerce_server/">Commerce Server 2009</a><br />
Thank you,<br />
Ing. Msc. Dan Gheorghe</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techyard.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techyard.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techyard.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techyard.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/techyard.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/techyard.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/techyard.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/techyard.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techyard.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techyard.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techyard.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techyard.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techyard.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techyard.wordpress.com/64/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techyard.wordpress.com&amp;blog=6899255&amp;post=64&amp;subd=techyard&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://techyard.wordpress.com/2009/10/07/working-with-sharepoint-large-lists/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/02d6c32b19fb86a8bf85cd576edcd46e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tech-yard</media:title>
		</media:content>

		<media:content url="http://techyard.files.wordpress.com/2009/10/comm.jpg" medium="image">
			<media:title type="html">Comm</media:title>
		</media:content>
	</item>
		<item>
		<title>Kill &#8220;Not responding&#8221; programs in windows with a shortcut.</title>
		<link>http://techyard.wordpress.com/2009/05/13/kill-not-responding-programs-in-windows-with-a-shortcut/</link>
		<comments>http://techyard.wordpress.com/2009/05/13/kill-not-responding-programs-in-windows-with-a-shortcut/#comments</comments>
		<pubDate>Wed, 13 May 2009 11:32:28 +0000</pubDate>
		<dc:creator>techyard</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[frozen application]]></category>
		<category><![CDATA[kill]]></category>
		<category><![CDATA[not respondig program]]></category>

		<guid isPermaLink="false">http://techyard.wordpress.com/?p=61</guid>
		<description><![CDATA[Please visit this : Samsung Service Galaxy S As i was stumbling around, i found this article . You can kill frozen application just with a double click on a shortcut on your desktop. You must create a new shortcut and in the location bar write : taskkill.exe /f /fi &#8220;status eq not responding&#8221; . Commerce [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techyard.wordpress.com&amp;blog=6899255&amp;post=61&amp;subd=techyard&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Please visit this :<strong><a title="Samsung Galaxy S" href="http://samsunggalaxysi900.wordpress.com/2011/05/07/why-not-samsung-galaxy-s-i9000-or-any-other-samsung-phone/"> Samsung Service Galaxy S</a></strong></p>
<p>As i was stumbling around, i found this <a href="http://www.switched.com/2009/05/04/kill-frozen-programs-in-windows-with-a-shortcut/">article</a> .<br />
You can kill frozen application just with a double click on a shortcut on your desktop.<br />
You must create a new shortcut and in the location bar write : taskkill.exe /f /fi &#8220;status eq not responding&#8221; .</p>
<p><a title="Commerce Server 2009" href="http://ronua.ro/CS/blogs/commerce_server/">Commerce Server 2009</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techyard.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techyard.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techyard.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techyard.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/techyard.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/techyard.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/techyard.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/techyard.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techyard.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techyard.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techyard.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techyard.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techyard.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techyard.wordpress.com/61/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techyard.wordpress.com&amp;blog=6899255&amp;post=61&amp;subd=techyard&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://techyard.wordpress.com/2009/05/13/kill-not-responding-programs-in-windows-with-a-shortcut/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/02d6c32b19fb86a8bf85cd576edcd46e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tech-yard</media:title>
		</media:content>
	</item>
		<item>
		<title>How to make index_changed event work for asp.net Gridview</title>
		<link>http://techyard.wordpress.com/2009/04/02/how-to-make-index_changed-event-work-for-aspnet-gridview/</link>
		<comments>http://techyard.wordpress.com/2009/04/02/how-to-make-index_changed-event-work-for-aspnet-gridview/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 13:17:05 +0000</pubDate>
		<dc:creator>techyard</dc:creator>
				<category><![CDATA[Asp.net]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[asp.net gridview]]></category>
		<category><![CDATA[command]]></category>
		<category><![CDATA[Gridview]]></category>
		<category><![CDATA[LinkButton]]></category>
		<category><![CDATA[Render override]]></category>
		<category><![CDATA[RowDataBound]]></category>
		<category><![CDATA[selected index changed]]></category>

		<guid isPermaLink="false">http://techyard.wordpress.com/?p=55</guid>
		<description><![CDATA[Please visit this : Samsung Service Galaxy S I have tried to work with indexchanged event of the asp.net gridview. It didn`t even enter the function. After some searching i found solution. You must add a column to the gridview typeof linkbutton. In the Command atribute type &#8220;Select&#8221; In the RowDataBound event attach the function GridView1_RowDataBound: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techyard.wordpress.com&amp;blog=6899255&amp;post=55&amp;subd=techyard&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Please visit this :<strong><a title="Samsung Galaxy S" href="http://samsunggalaxysi900.wordpress.com/2011/05/07/why-not-samsung-galaxy-s-i9000-or-any-other-samsung-phone/"> Samsung Service Galaxy S</a></strong></p>
<p>I have tried to work with indexchanged event of the asp.net gridview. It didn`t even enter the function. After some searching i found solution.<br />
You must add a column to the gridview typeof linkbutton.<br />
In the Command atribute type &#8220;Select&#8221;</p>
<p><img class="aligncenter size-full wp-image-59" title="addlinkbutton1" src="http://techyard.files.wordpress.com/2009/04/addlinkbutton1.jpg?w=450&#038;h=369" alt="addlinkbutton1" width="450" height="369" /></p>
<p>In the RowDataBound event attach the function GridView1_RowDataBound:</p>
<p>protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)<br />
{<br />
if (e.Row.RowType == DataControlRowType.DataRow)<br />
{<br />
if (e.Row.RowType == DataControlRowType.DataRow)<br />
{</p>
<p>// Get reference to button field in the gridview.<br />
LinkButton _singleClickButton = (LinkButton)e.Row.Cells[0].Controls[0];<br />
string _jsSingle = ClientScript.GetPostBackClientHyperlink(_singleClickButton, &#8220;Select$&#8221; + e.Row.RowIndex);<br />
e.Row.Style["cursor"] = &#8220;hand&#8221;;<br />
e.Row.Attributes["onclick"] = _jsSingle;</p>
<p>}<br />
}<br />
}</p>
<p>Now you must override the Render function:</p>
<p>protected override void Render(HtmlTextWriter writer)<br />
{<br />
foreach (GridViewRow row in GridView1.Rows)<br />
{<br />
if (row.RowType == DataControlRowType.DataRow)<br />
{<br />
ClientScript.RegisterForEventValidation(((LinkButton)row.Cells[0].Controls[0]).UniqueID, &#8220;Select$&#8221; + row.RowIndex);<br />
}<br />
}</p>
<p>base.Render(writer);<br />
}<br />
After this you can attach the indexChanged function to the gridview indexchanged event and get your row selected index when you click the row.</p>
<p>Ing. Msc. Dan Gheorghe</p>
<p><a title="Commerce Server 2009" href="http://ronua.ro/CS/blogs/commerce_server/">Commerce Server 2009</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techyard.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techyard.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techyard.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techyard.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/techyard.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/techyard.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/techyard.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/techyard.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techyard.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techyard.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techyard.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techyard.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techyard.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techyard.wordpress.com/55/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techyard.wordpress.com&amp;blog=6899255&amp;post=55&amp;subd=techyard&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://techyard.wordpress.com/2009/04/02/how-to-make-index_changed-event-work-for-aspnet-gridview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/02d6c32b19fb86a8bf85cd576edcd46e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tech-yard</media:title>
		</media:content>

		<media:content url="http://techyard.files.wordpress.com/2009/04/addlinkbutton1.jpg" medium="image">
			<media:title type="html">addlinkbutton1</media:title>
		</media:content>
	</item>
		<item>
		<title>Add RoleAssignment to listitem.</title>
		<link>http://techyard.wordpress.com/2009/03/26/add-roleassignment-to-listitem/</link>
		<comments>http://techyard.wordpress.com/2009/03/26/add-roleassignment-to-listitem/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 18:45:25 +0000</pubDate>
		<dc:creator>techyard</dc:creator>
				<category><![CDATA[Sharepoint/Wss 3.0]]></category>
		<category><![CDATA[AllowUnsafeUpdates]]></category>
		<category><![CDATA[Assignment]]></category>
		<category><![CDATA[BreakRoleInheritance]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[get requests]]></category>
		<category><![CDATA[list item]]></category>
		<category><![CDATA[Role]]></category>
		<category><![CDATA[RunWithElevatedPrivileges]]></category>
		<category><![CDATA[Sharepoint]]></category>
		<category><![CDATA[splistitem]]></category>
		<category><![CDATA[SPRoleAssignment]]></category>
		<category><![CDATA[SPRoleDefinitionCollection]]></category>
		<category><![CDATA[Updates are currently disallowed on GET requests]]></category>
		<category><![CDATA[user roles]]></category>

		<guid isPermaLink="false">http://techyard.wordpress.com/?p=48</guid>
		<description><![CDATA[Please visit this : Samsung Service Galaxy S This is continuing the previous post. After you create the list item impersonating the current logged in user in the sharepoint site you might want to give that user only the right to read it. After oListItem.Update(); you must run the code to do this with elevated Privileges [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techyard.wordpress.com&amp;blog=6899255&amp;post=48&amp;subd=techyard&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Please visit this :<strong><a title="Samsung Galaxy S" href="http://samsunggalaxysi900.wordpress.com/2011/05/07/why-not-samsung-galaxy-s-i9000-or-any-other-samsung-phone/"> Samsung Service Galaxy S</a></strong></p>
<p>This is continuing <a href="http://techyard.wordpress.com/2009/03/25/sharepoint-impersonation/">the previous post</a>. After you create the list item impersonating the current logged in user in the sharepoint site you might want to give that user only the right to read it.<br />
After oListItem.Update(); you must run the code to do this with elevated Privileges to assign the role.<br />
SPUser user = oWebsiteRoot.SiteUsers.GetByID(web.CurrentUser.ID);<br />
SPSecurity.RunWithElevatedPrivileges(delegate()<br />
{<br />
SPSite site = new SPSite(SPControl.GetContextSite(this.Context).ID);<br />
SPWeb w = site.OpenWeb();<br />
Guid g = oListItem.UniqueId;<br />
oListItem = w.Lists["Announcements"].GetItemByUniqueId(g);</p>
<p>oListItem is the listitem created in the previous post</p>
<p>I tried to set the RoleInheritence of the list item to false: oListItem.BreakRoleInheritance(false);<br />
but i had some problems with it. I got the error:<br />
&#8220;Updates are currently disallowed on GET requests.&#8221;</p>
<p>oListItem.BreakRoleInheritance(false) sets the spweb.AllowUnsafeUpdates to false; so after this you must set it true manually again even though we did that in the code before this (in the previous post) :</p>
<p>oListItem.BreakRoleInheritance(false);<br />
w.AllowUnsafeUpdates = true;<br />
w.Update();<br />
Now to set the roles:</p>
<p>SPRoleDefinitionCollection webroledefinitions = w.RoleDefinitions;</p>
<p>SPRoleAssignment roleassignment = new SPRoleAssignment(user);</p>
<p>roleassignment.RoleDefinitionBindings.Add(webroledefinitions["Read"]);<br />
oListItem.RoleAssignments.Add(roleassignment);<br />
oListItem.Update();</p>
<p>});</p>
<p>And now every user sees the the items created by themselves.</p>
<p><a title="Commerce Server 2009" href="http://ronua.ro/CS/blogs/commerce_server/">Commerce Server 2009</a><br />
By <a title="Commerce Server 2009" href="http://ronua.ro/CS/members/danghe/default.aspx">Ing. Msc. Dan Gheorghe</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techyard.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techyard.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techyard.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techyard.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/techyard.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/techyard.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/techyard.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/techyard.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techyard.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techyard.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techyard.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techyard.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techyard.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techyard.wordpress.com/48/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techyard.wordpress.com&amp;blog=6899255&amp;post=48&amp;subd=techyard&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://techyard.wordpress.com/2009/03/26/add-roleassignment-to-listitem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/02d6c32b19fb86a8bf85cd576edcd46e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tech-yard</media:title>
		</media:content>
	</item>
		<item>
		<title>Sharepoint Impersonation.</title>
		<link>http://techyard.wordpress.com/2009/03/25/sharepoint-impersonation/</link>
		<comments>http://techyard.wordpress.com/2009/03/25/sharepoint-impersonation/#comments</comments>
		<pubDate>Wed, 25 Mar 2009 16:34:15 +0000</pubDate>
		<dc:creator>techyard</dc:creator>
				<category><![CDATA[Sharepoint/Wss 3.0]]></category>
		<category><![CDATA[add new list item]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[get current user]]></category>
		<category><![CDATA[impersonation]]></category>
		<category><![CDATA[Sharepoint]]></category>
		<category><![CDATA[sharepoint impersonation]]></category>
		<category><![CDATA[usertoken]]></category>
		<category><![CDATA[webpart]]></category>
		<category><![CDATA[wss]]></category>

		<guid isPermaLink="false">http://techyard.wordpress.com/?p=42</guid>
		<description><![CDATA[Please visit this : Samsung Service Galaxy S When you create a web form or web part for wss or sharepoint and work with list items for example you should impersonate the current logged user in your application to see who modified, added the list item. I chose this example to be the simplest. So I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techyard.wordpress.com&amp;blog=6899255&amp;post=42&amp;subd=techyard&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Please visit this :<strong><a title="Samsung Galaxy S" href="http://samsunggalaxysi900.wordpress.com/2011/05/07/why-not-samsung-galaxy-s-i9000-or-any-other-samsung-phone/"> Samsung Service Galaxy S</a></strong></p>
<p>When you create a web form or web part for wss or sharepoint and work with list items for example you should impersonate the current logged user in your application to see who modified, added the list item. I chose this example to be the simplest.<br />
So I created a web part for my sharepoint site.</p>
<p>I added this to the default project created when you choose Sharepoint Web Part project:<br />
c# code:<br />
private string customMessage = &#8220;Hello, world!&#8221;;<br />
[WebBrowsable(true),<br />
WebDescription("Displays a custom message"),<br />
WebDisplayName("Display Message"),<br />
Personalizable(PersonalizationScope.User)]<br />
public string DisplayMessage<br />
{<br />
get { return customMessage; }<br />
set { customMessage = value; }</p>
<p>}<br />
In the render function i added my code. To make a similarity to asp.net you can think of it as page_load handler. Whenever you refresh the page that has the web part on it it executes your code.<br />
Here i get the current logged in user i display it on the screen and then i create a new item in the Announcements List as added by the user logged in:</p>
<p>protected override void Render(System.Web.UI.HtmlTextWriter writer)<br />
{<br />
try<br />
{<br />
HttpContext ctx = HttpContext.Current;<br />
SPWeb web = SPControl.GetContextWeb(this.Context);</p>
<p>if ( (ctx.User != null) &amp;&amp; (ctx.User.Identity != null))<br />
customMessage=ctx.User.Identity.Name;<br />
writer.Write(DisplayMessage);</p>
<p>And we show this way the current logged in user.<br />
Now we impersonate the user and create a new item in the Announcements list in his name. Every logged in user has a token (it identifies the authentication process applied to the user).<br />
SPSite impersonatedSiteCollection = new SPSite( SPControl.GetContextSite(this.Context).ID, token);<br />
SPWeb oWebsiteRoot = impersonatedSiteCollection.OpenWeb();<br />
oWebsiteRoot.AllowUnsafeUpdates = true;<br />
SPList oList = oWebsiteRoot.Lists["Announcements"];</p>
<p>SPListItem oListItem = oList.Items.Add();<br />
oListItem["Title"] = &#8220;My Item&#8221;;<br />
oListItem["Created"] = new DateTime(2004, 1, 23);<br />
oListItem["Modified"] = new DateTime(2005, 10, 1);<br />
oListItem.Update();<br />
}<br />
catch (System.ArgumentException e)<br />
{<br />
customMessage = e.Message ;<br />
writer.Write(DisplayMessage);<br />
}</p>
<p>I put it in a try catch sequence because the current logged in user might not have the rights to add a new item to that list and if so the page that contains the webpart will crash and he would not see it even though he has rights to. With the try catch the webpart will tell him that he has no rights.</p>
<p><a title="Commerce Server 2009" href="http://ronua.ro/CS/blogs/commerce_server/">Commerce Server 2009</a><br />
By <a title="Commerce Server 2009" href="http://ronua.ro/CS/members/danghe/default.aspx">Ing. Msc. Dan Gheorghe</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techyard.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techyard.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techyard.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techyard.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/techyard.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/techyard.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/techyard.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/techyard.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techyard.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techyard.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techyard.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techyard.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techyard.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techyard.wordpress.com/42/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techyard.wordpress.com&amp;blog=6899255&amp;post=42&amp;subd=techyard&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://techyard.wordpress.com/2009/03/25/sharepoint-impersonation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/02d6c32b19fb86a8bf85cd576edcd46e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tech-yard</media:title>
		</media:content>
	</item>
		<item>
		<title>DataGrid column width.</title>
		<link>http://techyard.wordpress.com/2009/03/10/datagrid-column-width/</link>
		<comments>http://techyard.wordpress.com/2009/03/10/datagrid-column-width/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 20:11:43 +0000</pubDate>
		<dc:creator>techyard</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[column]]></category>
		<category><![CDATA[DataGrid]]></category>
		<category><![CDATA[DataGridColumnStyle]]></category>
		<category><![CDATA[DataGridTableStyle]]></category>
		<category><![CDATA[width]]></category>

		<guid isPermaLink="false">http://techyard.wordpress.com/?p=17</guid>
		<description><![CDATA[Please visit this : Samsung Service Galaxy S I recently found out that the datagrid component doesn`t have the column property. The smartdevice project doesn`t have DataGridView in the toolbox, so you would have to work with the DataGrid componnent. [All code below is in C#] At first you must create a DataGridTableStyle : DataGridTableStyle ts [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techyard.wordpress.com&amp;blog=6899255&amp;post=17&amp;subd=techyard&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Please visit this :<strong><a title="Samsung Galaxy S" href="http://samsunggalaxysi900.wordpress.com/2011/05/07/why-not-samsung-galaxy-s-i9000-or-any-other-samsung-phone/"> Samsung Service Galaxy S</a></strong></p>
<p>I recently found out that the datagrid component doesn`t have the column property. The smartdevice project doesn`t have DataGridView in the toolbox, so you would have to work with the DataGrid componnent.</p>
<p>[All code below is in C#]<br />
At first you must create a DataGridTableStyle :</p>
<p><span style="color:#33cccc;">DataGridTableStyle </span>ts = <span style="color:#0000ff;">new </span><span style="color:#33cccc;">DataGridTableStyle</span>();</p>
<p>ts.MappingName = &#8220;&#8221;;</p>
<p>ts.GridColumnStyles.Clear();<br />
If you have a DataTable to use as a datasource for the grid :<br />
<code> </code></p>
<p><span style="color:#33cccc;">DataTable </span>t = getProduse();</p>
<p>Now if you have to create DataGridColumnStyles for each column in the datatable:<br />
<code> </code></p>
<p>for (<span style="color:#0000ff;">int </span>i = 0; i &lt; t.Columns.Count; i++)</p>
<p>{</p>
<p><span style="color:#33cccc;">DataGridColumnStyle </span>Col = <span style="color:#0000ff;">new </span><span style="color:#33cccc;">DataGridTextBoxColumn</span>();</p>
<p>Col.MappingName = t.Columns[i].ColumnName;</p>
<p>Col.HeaderText = t.Columns[i].ColumnName;</p>
<p>Col.Width = 400;</p>
<p>ts.GridColumnStyles.Add(Col);</p>
<p>}</p>
<p>After this you add the DataGridTableStyle to the DataGrid:<br />
<code>dataGrid1.TableStyles.Add(ts);</code><br />
Now when you select the DataSource the grid will have the Style you want:<br />
<code>dataGrid1.DataSource = t;</code></p>
<p><a title="Commerce Server 2009" href="http://ronua.ro/CS/blogs/commerce_server/">Commerce Server 2009</a><br />
By <a title="Commerce Server 2009" href="http://ronua.ro/CS/members/danghe/default.aspx">Ing. Msc. Dan Gheorghe</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techyard.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techyard.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techyard.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techyard.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/techyard.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/techyard.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/techyard.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/techyard.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techyard.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techyard.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techyard.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techyard.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techyard.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techyard.wordpress.com/17/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techyard.wordpress.com&amp;blog=6899255&amp;post=17&amp;subd=techyard&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://techyard.wordpress.com/2009/03/10/datagrid-column-width/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/02d6c32b19fb86a8bf85cd576edcd46e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tech-yard</media:title>
		</media:content>
	</item>
		<item>
		<title>Visual Studio 2008 Smart Device project connect to sql server.</title>
		<link>http://techyard.wordpress.com/2009/03/10/visual-studio-2008-smart-device-project-connect-to-sql-server/</link>
		<comments>http://techyard.wordpress.com/2009/03/10/visual-studio-2008-smart-device-project-connect-to-sql-server/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 14:07:45 +0000</pubDate>
		<dc:creator>techyard</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Sql Server]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[Device Emulator Manager]]></category>
		<category><![CDATA[device-emulator]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[Smart Device Project]]></category>
		<category><![CDATA[sql server network configuration]]></category>
		<category><![CDATA[tcp-ip]]></category>
		<category><![CDATA[Virtual PC]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Windows Mobile Device Center]]></category>

		<guid isPermaLink="false">http://techyard.wordpress.com/?p=4</guid>
		<description><![CDATA[Please visit this : Samsung Service Galaxy S A friend of mine ran into some trouble with a smart device project these days. At first with internet connectivity on the pocket pc emulation. After some heavy swearing and a lot of tries he managed to connect to the network and then to the sql server. There [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techyard.wordpress.com&amp;blog=6899255&amp;post=4&amp;subd=techyard&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Please visit this :<strong><a title="Samsung Galaxy S" href="http://samsunggalaxysi900.wordpress.com/2011/05/07/why-not-samsung-galaxy-s-i9000-or-any-other-samsung-phone/"> Samsung Service Galaxy S</a></strong></p>
<p>A friend of mine ran into some trouble with a<strong> smart device project</strong> these days. At first with internet connectivity on the pocket pc emulation. After some heavy swearing and a lot of tries he managed to connect to the network and then to<br />
the <strong>sql server</strong>. There are 2 steps here:</p>
<p>1.Connect to the network</p>
<p>2.Connect to the server</p>
<p>1.To connect to the local network through the pocket pc emulator you must install virtual pc and Windows Mobile Device Center.</p>
<p><a href="http://www.microsoft.com/downloadS/details.aspx?FamilyID=04d26402-3199-48a3-afa2-2dc0b40a73b6&amp;displaylang=en"><strong>Virtual PC</strong><br />
</a><br />
<strong><a href="http://www.microsoft.com/windowsmobile/en-us/help/synchronize/device-center.mspx">Windows Mobile Device Center.</a></strong></p>
<p>Run the <strong>Windows Mobile Device Center</strong> and use the following settings:</p>
<div id="attachment_7" class="wp-caption aligncenter" style="width: 459px"><img class="size-full wp-image-7" title="Windows Mobile Center Settings" src="http://techyard.files.wordpress.com/2009/03/mobilecenter1.jpg?w=450" alt="Windows  Mobile Center Settings"   /><p class="wp-caption-text">Windows Mobile Center Settings</p></div>
<p>Let it run in the <strong>background</strong>.</p>
<p>After you create the <strong>smart device</strong> project in<strong> visual studio</strong> you must enter <strong>Tools</strong>\<strong>Device Emulator Manager</strong>, choose the type of emulator you are using right click connect and right click cradle.</p>
<div id="attachment_9" class="wp-caption aligncenter" style="width: 426px"><img class="size-full wp-image-9" title="cradle" src="http://techyard.files.wordpress.com/2009/03/cradle.jpg?w=450" alt="cradle"   /><p class="wp-caption-text">cradle</p></div>
<p>In the emulator you must go to file\Configure to the<strong> Network Tab</strong> and enable the first checkbox.</p>
<div id="attachment_8" class="wp-caption aligncenter" style="width: 460px"><img class="size-full wp-image-8" title="pocketpc emulator network settings" src="http://techyard.files.wordpress.com/2009/03/pocketpcemulatornetworksettings.jpg?w=450&#038;h=349" alt="pocketpc emulator network settings" width="450" height="349" /><p class="wp-caption-text">pocketpc emulator network settings</p></div>
<p>Check in the windows mobile center program if it says connected in the lower left corner. If it didn&#8217;t connect reset the settings connect mode to Bluetooth or something else, click ok, and then reset tot <strong>DMA</strong> again.</p>
<p>2. The sql connection string mustn&#8217;t have the name of the server. You must use the ip and the port of the machine from the network where you have sql installed, for example: &#8220;<strong>Data Source</strong>=192.168.0.30,1433;&#8221;.</p>
<p>string <strong>ConnectionString</strong> = &#8220;Data Source=192.168.0.30,1433;Initial Catalog=Companies;User ID=admin2;Password=test&#8221;;</p>
<p><strong>1433</strong> is the default port that sql server uses.</p>
<p>If you try now it still won&#8217;t work.</p>
<p>You must enter in sql server configuration manager\sql server network configuration\protocols and enable TCP/IP, then go to sql server native client configuration\client protocols and enable TCP/IP here also.</p>
<p>Double click on the <strong>TCP\IP</strong> from <strong>network Configuration\protocols</strong>, enter the IP ADDRESSES tab and delete from top to bottom TCP Dynamic Ports (let it blank) and enter TCP port 1433 :</p>
<div id="attachment_10" class="wp-caption aligncenter" style="width: 460px"><img class="size-full wp-image-10" title="Sql Configuration Manager TCP\IP" src="http://techyard.files.wordpress.com/2009/03/tcpportconf.jpg?w=450&#038;h=259" alt="Sql Configuration Manager TCP\IP" width="450" height="259" /><p class="wp-caption-text">Sql Configuration Manager TCP\IP</p></div>
<p>After this you the application should connect to the<strong> sql server</strong>.</p>
<p><a title="Commerce Server 2009" href="http://ronua.ro/CS/blogs/commerce_server/">Commerce Server 2009</a><br />
By <a title="Commerce Server 2009" href="http://ronua.ro/CS/members/danghe/default.aspx">Ing. Msc. Dan Gheorghe</a></p>
<p>with the help of <a title="Commerce Server 2009" href="http://ronua.ro/CS/members/cmanole/default.aspx">Catalin Manole</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techyard.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techyard.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techyard.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techyard.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/techyard.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/techyard.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/techyard.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/techyard.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techyard.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techyard.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techyard.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techyard.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techyard.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techyard.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techyard.wordpress.com&amp;blog=6899255&amp;post=4&amp;subd=techyard&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://techyard.wordpress.com/2009/03/10/visual-studio-2008-smart-device-project-connect-to-sql-server/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/02d6c32b19fb86a8bf85cd576edcd46e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tech-yard</media:title>
		</media:content>

		<media:content url="http://techyard.files.wordpress.com/2009/03/mobilecenter1.jpg" medium="image">
			<media:title type="html">Windows Mobile Center Settings</media:title>
		</media:content>

		<media:content url="http://techyard.files.wordpress.com/2009/03/cradle.jpg" medium="image">
			<media:title type="html">cradle</media:title>
		</media:content>

		<media:content url="http://techyard.files.wordpress.com/2009/03/pocketpcemulatornetworksettings.jpg" medium="image">
			<media:title type="html">pocketpc emulator network settings</media:title>
		</media:content>

		<media:content url="http://techyard.files.wordpress.com/2009/03/tcpportconf.jpg" medium="image">
			<media:title type="html">Sql Configuration Manager TCP\IP</media:title>
		</media:content>
	</item>
	</channel>
</rss>
