<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Custom Server Controls</title><link>http://forums.asp.net/19.aspx</link><description>All about building ASP.NET server controls. &lt;a href="http://aspadvice.com/SignUp/list.aspx?l=12&amp;c=17" target="_blank"&gt;Email List&lt;/a&gt;</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: ListControl added as child controls does remember selected items on postback</title><link>http://forums.asp.net/thread/3275213.aspx</link><pubDate>Sun, 05 Jul 2009 08:38:14 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3275213</guid><dc:creator>Abdulla.AbdelHaq</dc:creator><author>Abdulla.AbdelHaq</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3275213.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=19&amp;PostID=3275213</wfw:commentRss><description>&lt;p&gt;you need to add the items in the Render Method not inthe CreateChildControls. &lt;/p&gt;&lt;p&gt;just move the listitems parts to be in the Render Method.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;pre name="code" class="vb.net"&gt;Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)

 End Sub&lt;/pre&gt;&lt;p&gt;&lt;br /&gt; &lt;br /&gt;&lt;/p&gt;</description></item><item><title>ListControl added as child controls does remember selected items on postback</title><link>http://forums.asp.net/thread/3274825.aspx</link><pubDate>Sat, 04 Jul 2009 16:35:12 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3274825</guid><dc:creator>bhav27</dc:creator><author>bhav27</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3274825.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=19&amp;PostID=3274825</wfw:commentRss><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I am get very frustrated while added listcontrol inside my custom server control. Basically, these controls does not remember what items user selected when postback occurs.&lt;/p&gt;
&lt;p&gt;Just to test this I have created following code. Checkboxlist remembers its items collection but for some bizzare reason does not remember checked items when postback occurs. Please can someone provide me solution or direct me to correct resource;&lt;/p&gt;&lt;pre class="c-sharp" name="code"&gt;using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace AspNetServerControls
{
	[ToolboxData(&amp;quot;&amp;lt;{0}:TestingViewStates runat=server&amp;gt;&amp;lt;/{0}:TestingViewStates&amp;gt;&amp;quot;)]
	public class TestingViewStates : WebControl
	{
		protected override void CreateChildControls()
		{
			CheckBoxList chkList = new CheckBoxList();
			chkList.EnableViewState = true;
			Controls.Add(chkList);

			if (chkList.Items.Count == 0)
			{
				List&amp;lt;string&amp;gt; items = new List&amp;lt;string&amp;gt;();
				items.Add(&amp;quot;London&amp;quot;);
				items.Add(&amp;quot;New York&amp;quot;);
				items.Add(&amp;quot;Paris&amp;quot;);

				chkList.DataSource = items;
				chkList.DataBind();
			}
			
			base.CreateChildControls();
		}
	}
}
&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>