<?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/"
	>

<channel>
	<title>Welcome to ShanthaKumar&#039;s Blog &#187; List</title>
	<atom:link href="http://ktskumar.com/blog/tag/list/feed/" rel="self" type="application/rss+xml" />
	<link>http://ktskumar.com/blog</link>
	<description>SharePoint, Silverlight and more.........</description>
	<lastBuildDate>Thu, 10 Jun 2010 01:42:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to get InternalName in ListEdit Page</title>
		<link>http://ktskumar.com/blog/2009/09/25/how-to-get-internalname-in-listedit-page/</link>
		<comments>http://ktskumar.com/blog/2009/09/25/how-to-get-internalname-in-listedit-page/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 01:09:08 +0000</pubDate>
		<dc:creator>Shantha Kumar</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Coulmns]]></category>
		<category><![CDATA[Customize]]></category>
		<category><![CDATA[Field]]></category>
		<category><![CDATA[InternalName]]></category>
		<category><![CDATA[List]]></category>
		<category><![CDATA[listedit]]></category>
		<category><![CDATA[spField]]></category>

		<guid isPermaLink="false">http://ktskumar.com/blog/?p=242</guid>
		<description><![CDATA[In SharePoint the column or field has two names. One is DisplayName, used to view the field name publically in all pages and another is InternalName used internally to refer the Field. This Internal name will be used in CAML Queries, during retreiving inserting and updating the list item.We can&#8217;t see this Internal name in any pages [...]]]></description>
			<content:encoded><![CDATA[<p>In SharePoint the column or field has two names. One is DisplayName, used to view the field name publically in all pages and another is InternalName used internally to refer the Field. This Internal name will be used in CAML Queries, during retreiving inserting and updating the list item.We can&#8217;t see this Internal name in any pages normally, but we can do some work around for getting this internalnames, such as writing the code  &amp; look in to the url of the particular field.</p>
<p>Now i giving a simple tip on displaying the InternalName on ListEdit page itself, this will help us in knowing internal name quickly and consume the time when we work up on List and ListItems.</p>
<div style="margin:left:0px">
<ul>
<li>For that, we have to edit the ListEdit.aspx page, which is available under &lt;System Folder&gt;:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\</li>
<li>Before going to edit that page, backup that file and open it. This is the screenshot, taken before editing the page,<br />
<a href="http://ktskumar.com/blog/wp-content/uploads/2009/09/lstedit1.JPG" target=_blank"><img src="http://ktskumar.com/blog/wp-content/uploads/2009/09/lstedit1.JPG" alt="Displaying ListEdit Page without Internal Names" /></a></li>
<li>In the ListEdit page, add the Column as InternalName under Columns section,To add the header for Internalname under Columns section, Search for the following line<br />
<em>for (Int32 iIndex = 0; iIndex &lt; spFields.Count; iIndex ++ )</em></li>
<li>At first we have to add the header column, for that before the above searched  line there is &lt;TR&gt; tag with three header &lt;TH&gt; tags, add the following &lt;TH&gt; within the &lt;TR&gt; tag,<strong>&lt;TH scope=&#8221;col&#8221;-vh2-nofilter width=25% id=&#8221;TH1&#8243;&gt;Internal Name&lt;/TH&gt;</strong>After adding the line, the code look like this,
<div class="codecss" style="font-size:11px;">&lt;TR&gt;<br />
&lt;TH scope=&#8221;col&#8221;-vh2-nofilter width=25% id=&#8221;1600&#8243;&gt;<br />
&lt;SharePoint:EncodedLiteral runat=&#8221;server&#8221; text=&#8221;&lt;%$Resources:wss,listedit_columnclicktoedit%&gt;&#8221; EncodeMethod=&#8217;HtmlEncode&#8217;/&gt;<br />
&lt;/TH&gt;<br />
&lt;TH scope=&#8221;col&#8221;-vh2-nofilter width=25% id=&#8221;1700&#8243;&gt;<br />
&lt;SharePoint:EncodedLiteral runat=&#8221;server&#8221; text=&#8221;&lt;%$Resources:wss,listedit_type%&gt;&#8221; EncodeMethod=&#8217;HtmlEncode&#8217;/&gt;<br />
&lt;/TH&gt;<br />
&lt;TH scope=&#8221;col&#8221;-vh2-nofilter colspan=2 id=&#8221;1800&#8243;&gt;<br />
&lt;% if (!spList.ContentTypesEnabled) { %&gt;<br />
&lt;SharePoint:EncodedLiteral runat=&#8221;server&#8221; text=&#8221;&lt;%$Resources:wss,listedit_required%&gt;&#8221; EncodeMethod=&#8217;HtmlEncode&#8217;/&gt;<br />
&lt;% } else { %&gt;<br />
&lt;SharePoint:EncodedLiteral runat=&#8221;server&#8221; text=&#8221;&lt;%$Resources:wss,listedit_used_in%&gt;&#8221; EncodeMethod=&#8217;HtmlEncode&#8217;/&gt;<br />
&lt;% } %&gt;<br />
&lt;/TH&gt;<br />
<strong>&lt;TH scope=&#8221;col&#8221;-vh2-nofilter width=25% id=&#8221;TH1&#8243;&gt;Internal Name&lt;/TH&gt;<br />
</strong>&lt;/TR&gt;<br />
for (Int32 iIndex = 0; iIndex &lt; spFields.Count; iIndex ++ )
</div>
</li>
<li>And then we have to add the InternalName for each field type, for that<br />
Search for the following if condition line,</p>
<p><em>if (spField.ReadOnlyField &amp;&amp; !bCountRelated)</em></p>
<p>The above line checks the current field is read only or not, by default the read only fields are User and Calculated Columns</li>
<li>If you look in to the page, you can able to see the switch case statement under the if condition. Switch case statement checks the each read-only field type and adding the row contents such as (Display name, field type and Require or not) columns based on the field type,so we have to add the following line (column) within each case statement,
<p><strong>&lt;TD-vb2&gt;&lt;%SPHttpUtility.UrlKeyValueEncode(spField.InternalName, Response.Output);%&gt;&lt;/TD&gt;</strong></p>
<p>In this page, spField.InternalName displays the Internal Name for the current field type.</p>
<p>The above TD tag content ensures that, the each field row has its own Internalname</li>
<li>The else condition refers to the non-read only fields, If we add this line <strong>&lt;TD-vb2&gt;&lt;%SPHttpUtility.UrlKeyValueEncode(spField.InternalName, Response.Output);%&gt;&lt;/TD&gt;</strong>, the internal Name will be appeared on all the non-read only field types.</li>
<p>After adding all the lines, the code for the if and else condition will be look like this,</p>
<div class="codecss" style="font-size:11px;">if (spField.ReadOnlyField &amp;&amp; !bCountRelated)<br />
{<br />
switch (spField.Type)<br />
{<br />
case SPFieldType.Calculated:<br />
rowClass = (rowClass == &#8220;&#8221;)? &#8220;ms-alternating&#8221; : &#8220;&#8221;;<br />
%&gt;<br />
&lt;TR&gt;<br />
&lt;TD-vb2&gt;<br />
&lt;A ID=&#8221;LinkEditField&lt;%= Convert.ToString(iIndex) %&gt;&#8221; HREF=&#8221;FldEdit.aspx?List=&lt;%SPHttpUtility.UrlKeyValueEncode(spList.ID.ToString(&#8221;B&#8221;).ToUpper(), Response.Output);%&gt;&amp;Field=&lt;%SPHttpUtility.UrlKeyValueEncode(spField.InternalName, Response.Output);%&gt;&#8221;&gt; &lt;%SPHttpUtility.HtmlEncode(spField.Title,Response.Output);%&gt;<br />
&lt;/A&gt;<br />
&lt;/TD&gt;<br />
&lt;TD-vb2&gt;<br />
&lt;SharePoint:EncodedLiteral runat=&#8221;server&#8221; text=&#8221;&lt;%$Resources:wss,listedit_calculated%&gt;&#8221; EncodeMethod=&#8217;HtmlEncode&#8217;/&gt;<br />
&lt;/TD&gt;<br />
&lt;TD colspan=2-vb2&gt;<br />
&lt;%SPHttpUtility.HtmlEncode(GetUsedIn(spField), Response.Output);%&gt;<br />
&lt;/TD&gt;<br />
<strong>&lt;TD-vb2&gt;<br />
&lt;%SPHttpUtility.UrlKeyValueEncode(spField.InternalName, Response.Output);%&gt;<br />
&lt;/TD&gt;</strong><br />
&lt;/TR&gt;<br />
&lt;%<br />
break;<br />
case SPFieldType.User:<br />
rowClass = (rowClass == &#8220;&#8221;)? &#8220;ms-alternating&#8221; : &#8220;&#8221;;<br />
%&gt;<br />
&lt;TR&gt;<br />
&lt;TD-vb2&gt;<br />
&lt;A ID=&#8221;LinkEditField&lt;%= Convert.ToString(iIndex) %&gt;&#8221; HREF=&#8221;FldEditEx.aspx?List=&lt;%SPHttpUtility.UrlKeyValueEncode(spList.ID.ToString(&#8221;B&#8221;).ToUpper(), Response.Output);%&gt;&amp;Field=&lt;%SPHttpUtility.UrlKeyValueEncode(spField.InternalName, Response.Output);%&gt;&#8221; &gt; &lt;%SPHttpUtility.HtmlEncode(spField.Title,Response.Output);%&gt;&lt;/A&gt;<br />
&lt;/TD&gt;<br />
&lt;TD-vb2&gt;&lt;%SPHttpUtility.HtmlEncode(spField.TypeDisplayName, Response.Output);%&gt;<br />
&lt;/TD&gt;<br />
&lt;TD colspan=2-vb2&gt;&lt;%SPHttpUtility.HtmlEncode(GetUsedIn(spField), Response.Output);%&gt;<br />
&lt;/TD&gt;<br />
<strong>&lt;TD-vb2&gt;<br />
&lt;%SPHttpUtility.UrlKeyValueEncode(spField.InternalName, Response.Output);%&gt;<br />
&lt;/TD&gt;<br />
</strong>&lt;/TR&gt;<br />
&lt;%<br />
break;<br />
default:<br />
if (spField.XPath != null &amp;&amp; !spField.Hidden)<br />
{<br />
%&gt;<br />
&lt;TR&gt;<br />
&lt;TD-vb2&gt;<br />
&lt;%SPHttpUtility.HtmlEncode(spField.Title,Response.Output);%&gt;<br />
&lt;/TD&gt;<br />
&lt;TD-vb2&gt;&lt;%SPHttpUtility.HtmlEncode(spField.TypeDisplayName, Response.Output);%&gt;&lt;/TD&gt;<br />
&lt;TD colspan=2-vb2&gt;<br />
&lt;% if ( !spList.ContentTypesEnabled &amp;&amp; spField.Required == true ) { %&gt; &lt;IMG SRC=&#8221;/_layouts/images/check.gif&#8221; alt=&#8221;Checked&#8221;&gt; &lt;% ; } %&gt;<br />
&lt;%SPHttpUtility.HtmlEncode(GetUsedIn(spField), Response.Output);%&gt;<br />
&lt;/TD&gt;<br />
<strong>&lt;TD-vb2&gt;<br />
&lt;%SPHttpUtility.UrlKeyValueEncode(spField.InternalName, Response.Output);%&gt;<br />
&lt;/TD&gt;<br />
</strong>&lt;/TR&gt;<br />
&lt;%<br />
}<br />
break;<br />
}<br />
}<br />
else<br />
{<br />
rowClass = (rowClass == &#8220;&#8221;)? &#8220;ms-alternating&#8221; : &#8220;&#8221;;<br />
%&gt;<br />
&lt;TR&gt;&lt;TD-vb2&gt;<br />
&lt;%if (Enum.IsDefined(typeof(SPFieldType), spField.TypeAsString) &amp;&amp; spField.Type != SPFieldType.Lookup &amp;&amp; spField.Type != SPFieldType.User) {%&gt;<br />
&lt;A ID=&#8221;LinkEditField&lt;%= Convert.ToString(iIndex) %&gt;&#8221; HREF=&#8221;FldEdit.aspx?List=&lt;%SPHttpUtility.UrlKeyValueEncode(spList.ID.ToString(&#8221;B&#8221;).ToUpper(), Response.Output);%&gt;&amp;Field=&lt;%SPHttpUtility.UrlKeyValueEncode(spField.InternalName, Response.Output);%&gt;&#8221;&gt; &lt;%SPHttpUtility.HtmlEncode(spField.Title,Response.Output);%&gt;&lt;/A&gt;<br />
&lt;%} else {%&gt;<br />
&lt;A ID=&#8221;LinkEditField&lt;%= Convert.ToString(iIndex) %&gt;&#8221; HREF=&#8221;FldEditEx.aspx?List=&lt;%SPHttpUtility.UrlKeyValueEncode(spList.ID.ToString(&#8221;B&#8221;).ToUpper(), Response.Output);%&gt;&amp;Field=&lt;%SPHttpUtility.UrlKeyValueEncode(spField.InternalName, Response.Output);%&gt;&#8221;&gt; &lt;%SPHttpUtility.HtmlEncode(spField.Title,Response.Output);%&gt;&lt;/A&gt;<br />
&lt;%}%&gt;<br />
&lt;/TD&gt;<br />
&lt;TD-vb2&gt;&lt;%SPHttpUtility.HtmlEncode(spField.TypeDisplayName, Response.Output);%&gt;&lt;/TD&gt;<br />
&lt;TD<br />
colspan=2<br />
class=ms-vb2&gt;<br />
&lt;% if ( !spList.ContentTypesEnabled &amp;&amp; spField.Required == true ) { %&gt; &lt;IMG SRC=&#8221;/_layouts/images/check.gif&#8221; alt=&#8221;Checked&#8221;&gt; &lt;% ; } %&gt;<br />
&lt;%SPHttpUtility.HtmlEncode(GetUsedIn(spField), Response.Output);%&gt;<br />
&lt;/TD&gt;<br />
<strong>&lt;TD-vb2&gt;<br />
&lt;%SPHttpUtility.UrlKeyValueEncode(spField.InternalName, Response.Output);%&gt;<br />
&lt;/TD&gt;</strong><br />
&lt;/TR&gt;<br />
&lt;%<br />
}</div>
<p>The final outcome will be as follows,<br />
<a href="http://ktskumar.com/blog/wp-content/uploads/2009/09/lstedit2.JPG" target="_blank"><img src="http://ktskumar.com/blog/wp-content/uploads/2009/09/lstedit2.JPG" alt="Displaying ListEdit Page with Internal Names" /></a></ul>
</div>
<p>To download the listedit.aspx page, click <a href="http://ktskumar.com/blog/wp-content/uploads/2009/09/listedit.txt" target="_blank">here</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://ktskumar.com/blog/2009/09/25/how-to-get-internalname-in-listedit-page/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Uploading File from Local Machine to SharePoint ListItem as an attachment</title>
		<link>http://ktskumar.com/blog/2008/03/31/uploading-file-from-local-machine-to-sharepoint-listitem-as-an-attachment/</link>
		<comments>http://ktskumar.com/blog/2008/03/31/uploading-file-from-local-machine-to-sharepoint-listitem-as-an-attachment/#comments</comments>
		<pubDate>Mon, 31 Mar 2008 05:04:19 +0000</pubDate>
		<dc:creator>Shantha Kumar</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Attachment]]></category>
		<category><![CDATA[File]]></category>
		<category><![CDATA[List]]></category>
		<category><![CDATA[ListIte]]></category>
		<category><![CDATA[MOSS]]></category>
		<category><![CDATA[Upload]]></category>

		<guid isPermaLink="false">http://ktskumar.wordpress.com/?p=17</guid>
		<description><![CDATA[To attach the file from Local Machine to SharePoint ListItem as an attachment, Import the System.IO namespace to use the Stream Class to read the file contents.

Use System.Web.UI.WebControls.FileUpload control is named as fileUpload in code. 
Sample code for uploading the file from Local Machine to ListItem attachments as follows,
//Check the FileUpload control has the file
if (fileUpload.PostedFile [...]]]></description>
			<content:encoded><![CDATA[<p style="margin:0 0 10pt;" class="MsoNormal"><font face="Times New Roman">To attach the file from Local Machine to SharePoint ListItem as an attachment, </font><span style="font-size:11pt;line-height:115%;font-family:Calibri;"><font face="Times New Roman">Import the <strong>System.IO</strong> namespace to use the <strong>Stream</strong> Class to read the file contents.</font></span></p>
<p><span style="font-size:11pt;line-height:115%;font-family:Calibri;"></span><span style="font-size:11pt;line-height:115%;font-family:Calibri;"></span><span style="font-size:11pt;line-height:115%;font-family:Calibri;"></span><span style="font-size:11pt;line-height:115%;font-family:Calibri;"></span><span style="font-size:11pt;line-height:115%;font-family:Calibri;"></p>
<p style="margin:0 0 10pt;" class="MsoNormal"><font face="Times New Roman">Use System.Web.UI.WebControls.FileUpload control is named as fileUpload in code. </font></p>
<p style="margin:0 0 10pt;" class="MsoNormal">Sample code for uploading the file from Local Machine to ListItem attachments as follows,</p>
<p><span style="font-size:10pt;color:green;font-family:'Courier New';">//Check the FileUpload control has the file</span></p>
<p><span style="font-size:10pt;color:green;font-family:'Courier New';"></span><span style="font-size:10pt;color:blue;font-family:'Courier New';">if</span><span style="font-size:10pt;font-family:'Courier New';"> (fileUpload.PostedFile != <span style="color:blue;">null</span>)</span></p>
<p><span style="font-size:10pt;font-family:'Courier New';"></span><span style="font-size:10pt;font-family:'Courier New';"></span><span style="font-size:10pt;font-family:'Courier New';">{</span><span style="font-size:10pt;font-family:'Courier New';">item = list.Items.Add();</span></p>
<p><span style="font-size:10pt;font-family:'Courier New';"></span><span style="font-size:10pt;font-family:'Courier New';">item[<span style="color:#a31515;">"Title"</span>] = fileUpload.FileName;</span></p>
<p><span style="font-size:10pt;font-family:'Courier New';"></span><span style="font-size:10pt;color:green;font-family:'Courier New';">//Read the Contents from the file in Local machine</span></p>
<p><span style="font-size:10pt;color:green;font-family:'Courier New';"></span><span style="font-size:10pt;color:#2b91af;font-family:'Courier New';">Stream</span><span style="font-size:10pt;font-family:'Courier New';"> fs = fileUpload.PostedFile.InputStream;<span>                    </span></span></p>
<p><span style="font-size:10pt;font-family:'Courier New';"><span></span></span><span style="font-size:10pt;color:blue;font-family:'Courier New';">byte</span><span style="font-size:10pt;font-family:'Courier New';">[] fileContents = <span style="color:blue;">new</span> <span style="color:blue;">byte</span>[fs.Length];</span></p>
<p><span style="font-size:10pt;font-family:'Courier New';"></span><span style="font-size:10pt;font-family:'Courier New';">fs.Read(fileContents, 0, (<span style="color:blue;">int</span>)fs.Length);</span></p>
<p><span style="font-size:10pt;font-family:'Courier New';"></span><span style="font-size:10pt;font-family:'Courier New';">fs.Close();</span></p>
<p><span style="font-size:10pt;font-family:'Courier New';"></span><span style="font-size:10pt;color:green;font-family:'Courier New';">// Add the file to the ListItem as an Attachment</span></p>
<p><span style="font-size:10pt;color:green;font-family:'Courier New';"></span><span style="font-size:10pt;color:#2b91af;font-family:'Courier New';">SPAttachmentCollection</span><span style="font-size:10pt;font-family:'Courier New';"> attachments = item.Attachments;</span></p>
<p><span style="font-size:10pt;font-family:'Courier New';"></span><span style="font-size:10pt;color:blue;font-family:'Courier New';">string</span><span style="font-size:10pt;font-family:'Courier New';"> fileName = <span style="color:#2b91af;">Path</span>.GetFileName(fileUpload.PostedFile.FileName);</span></p>
<p><span style="font-size:10pt;font-family:'Courier New';"></span><span style="font-size:10pt;font-family:'Courier New';">attachments.Add(fileName, fileContents);</span><span style="font-size:10pt;font-family:'Courier New';"><span> </span></span></p>
<p><span style="font-size:10pt;font-family:'Courier New';"><span></span>item.Update();<span>                                            </span></span></p>
<p style="margin:0 0 10pt;" class="MsoNormal"><span style="font-size:10pt;line-height:115%;font-family:'Courier New';">}</span></p>
<p></span></p>
]]></content:encoded>
			<wfw:commentRss>http://ktskumar.com/blog/2008/03/31/uploading-file-from-local-machine-to-sharepoint-listitem-as-an-attachment/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
