Accessing list item shows null, but items are there in discussion board<p>Hi All,</p> <p>I am trying to itrate DISCUSSION BOARD items(threads),<br/>and List.ItemCount shows 2 items, but when i try to access <br/>items, it shows listItem null, and debugger comes out of loop</p> <p>     SPList list=web.Lists[&quot;DBoard&quot;];<br/>            int i = list.ItemCount;<br/>            foreach (SPListItem listItem in list.Items)<br/>            {</p> <p><br/>            }</p> <p>I am not able to find, what i am doing wrong here.</p><hr class="sig">arun singh© 2009 Microsoft Corporation. All rights reserved.Fri, 03 Jul 2009 14:59:45 Z634222e7-e77d-401d-a4f7-c3728ec46a8ahttp://social.technet.microsoft.com/Forums/en-US/sharepointdevelopment/thread/634222e7-e77d-401d-a4f7-c3728ec46a8a#634222e7-e77d-401d-a4f7-c3728ec46a8ahttp://social.technet.microsoft.com/Forums/en-US/sharepointdevelopment/thread/634222e7-e77d-401d-a4f7-c3728ec46a8a#634222e7-e77d-401d-a4f7-c3728ec46a8aarun_inhttp://social.technet.microsoft.com/Profile/en-US/?user=arun_inAccessing list item shows null, but items are there in discussion board<p>Hi All,</p> <p>I am trying to itrate DISCUSSION BOARD items(threads),<br/>and List.ItemCount shows 2 items, but when i try to access <br/>items, it shows listItem null, and debugger comes out of loop</p> <p>     SPList list=web.Lists[&quot;DBoard&quot;];<br/>            int i = list.ItemCount;<br/>            foreach (SPListItem listItem in list.Items)<br/>            {</p> <p><br/>            }</p> <p>I am not able to find, what i am doing wrong here.</p><hr class="sig">arun singhFri, 03 Jul 2009 14:10:01 Z2009-07-03T14:10:01Zhttp://social.technet.microsoft.com/Forums/en-US/sharepointdevelopment/thread/634222e7-e77d-401d-a4f7-c3728ec46a8a#a42190ee-5535-4453-9757-71da106ccb21http://social.technet.microsoft.com/Forums/en-US/sharepointdevelopment/thread/634222e7-e77d-401d-a4f7-c3728ec46a8a#a42190ee-5535-4453-9757-71da106ccb21Naresh kilaru [MCTS]http://social.technet.microsoft.com/Profile/en-US/?user=Naresh%20kilaru%20%5bMCTS%5dAccessing list item shows null, but items are there in discussion boardHope this may helps you.<br/> <br/> http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/afe07483-6aec-424a-9434-c8e8b963e55cFri, 03 Jul 2009 14:28:03 Z2009-07-03T14:28:03Zhttp://social.technet.microsoft.com/Forums/en-US/sharepointdevelopment/thread/634222e7-e77d-401d-a4f7-c3728ec46a8a#b7753485-2aaf-4281-856f-01a9351a9a00http://social.technet.microsoft.com/Forums/en-US/sharepointdevelopment/thread/634222e7-e77d-401d-a4f7-c3728ec46a8a#b7753485-2aaf-4281-856f-01a9351a9a00SP RAJhttp://social.technet.microsoft.com/Profile/en-US/?user=SP%20RAJAccessing list item shows null, but items are there in discussion boardArun, you can try the below code<br/> <br/> <pre lang="x-c#">SPList list = myweb.Lists[&quot;DBoard&quot;]; SPQuery myquery = new SPQuery(); myquery.Query = &quot;&lt;Query&gt;&lt;OrderBy&gt;&lt;FieldRef Name='Subject'/&gt;&lt;/OrderBy&gt;&lt;/Query&gt;&quot;; SPListItemCollection myitemcol = list.GetItems(myquery); DropDownList1.Items.Clear(); DropDownList1.AppendDataBoundItems = true; DropDownList1.Items.Add(new ListItem(&quot;Select...&quot;, &quot;&quot;)); foreach (SPListItem listitem in myitemcol) { DropDownList1.Items.Add(new ListItem(listitem[&quot;Subject&quot;].ToString())); }</pre> <br/> <br/> <br/>Fri, 03 Jul 2009 14:44:19 Z2009-07-03T14:44:19Zhttp://social.technet.microsoft.com/Forums/en-US/sharepointdevelopment/thread/634222e7-e77d-401d-a4f7-c3728ec46a8a#165b4a37-0352-426a-8fac-ccb37bf99d17http://social.technet.microsoft.com/Forums/en-US/sharepointdevelopment/thread/634222e7-e77d-401d-a4f7-c3728ec46a8a#165b4a37-0352-426a-8fac-ccb37bf99d17arun_inhttp://social.technet.microsoft.com/Profile/en-US/?user=arun_inAccessing list item shows null, but items are there in discussion boardHi RAJ,<br/><br/>Actually i am using SPEmailEventReciever handler, inside that i placed ur code...<br/><br/>But as usual it is coming from loop <br/><span style="color:blue"><br/>foreach</span> (SPListItem listitem <span style="color:blue">in</span> myitemcol)<br/>            {<br/>                DropDownList1.Items.Add(<span style="color:blue">new</span> ListItem(listitem[<span style="color:#a31515">&quot;Subject&quot;</span>].ToString()));<br/>            }<br/><br/>as it is not getting item in the collection.<br/>I dont know what is happening here.<hr class="sig">arun singhFri, 03 Jul 2009 14:59:45 Z2009-07-03T14:59:45Z