Hi,

I am creating the grid panel dynamically as given in the below URL.

http://looksharp.dk/post/2012/05/13/...odebehind.aspx

I want to dynamically add a dropdownlist control to one of the Columns. I tried both in "TemplateString" and "TemplateControl" but both failed. i have posted the code below can anyone provide samples on how to add controls to the Grid columns.

TemplateString
I created a TemplateColumn and inside it i used the TemplateString= "<asp:DropDownList runat='server' DataSource='" + sqlDS+"' DataTextField='LastName'></asp:DropDownList>". The sqlDS is SQLDatasource created dynamically. This does not throw me any error but i can not find any controls. But if i provide the below string then it works normally and displays
TemplateString = "<Html><div>Test Message</div></Html>"

TemplateControl

i created a class and inherited from TemplateControl as below

[ParseChildren(true)]
[PersistChildren(false)]
public class HelloWorldTemplateControl : TemplateControl
{
private ITemplate _helloTemplate;

[PersistenceMode(PersistenceMode.InnerProperty),
TemplateContainer(typeof(HelloWorldTemplateControl ))]
public ITemplate HelloTemplate
{
get { return _helloTemplate; }
set { _helloTemplate = value; }
}

protected override void CreateChildControls()
{
Controls.Clear();
if (HelloTemplate != null)
{
HelloTemplate.InstantiateIn(this);
}
}
}

At runtime i get "Compile" object is null.

Please suggest me.