M
Mr Not So Know It All
i found this code to create dynamic itemtemplates on the microsoft
site. here's the url:
Creating Web Server Control Templates Programmatically
http://msdn.microsoft.com/library/d...webservercontroltemplatesprogrammatically.asp
here's the code I'm using..
public void InstantiateIn(System.Web.UI.Control container)
{
Literal lc = new Literal();
Button btn = new Button();
switch (templateType)
{
case ListItemType.Header:
lc.Text = "<TABLE
border=1><TR><TH>Count</TH><TH>Items</TH></TR>";
break;
case ListItemType.Item:
lc.Text = "<TR><TD>Item number: " +
itemcount.ToString() + "</TD><TD>";
lc.DataBinding += new
EventHandler(TemplateControl_DataBinding);
btn.DataBinding +=new
EventHandler(TemplateControlBTN_DataBinding);
break;
case ListItemType.AlternatingItem:
lc.Text = "<TR><TD bgcolor=lightblue>Item number: " +
itemcount.ToString() + "</TD><TD>";
lc.DataBinding += new
EventHandler(TemplateControl_DataBinding);
break;
case ListItemType.Footer:
lc.Text = "</TABLE>";
break;
}
container.Controls.Add(lc);
itemcount += 1;
}
as you can see, the code dynamically adds a literal control to the item
template. can someone please help me add other controls like a button?
i would really like to add a table control and not have to use a
literal control to add the table control.
thanks for all your help.
site. here's the url:
Creating Web Server Control Templates Programmatically
http://msdn.microsoft.com/library/d...webservercontroltemplatesprogrammatically.asp
here's the code I'm using..
public void InstantiateIn(System.Web.UI.Control container)
{
Literal lc = new Literal();
Button btn = new Button();
switch (templateType)
{
case ListItemType.Header:
lc.Text = "<TABLE
border=1><TR><TH>Count</TH><TH>Items</TH></TR>";
break;
case ListItemType.Item:
lc.Text = "<TR><TD>Item number: " +
itemcount.ToString() + "</TD><TD>";
lc.DataBinding += new
EventHandler(TemplateControl_DataBinding);
btn.DataBinding +=new
EventHandler(TemplateControlBTN_DataBinding);
break;
case ListItemType.AlternatingItem:
lc.Text = "<TR><TD bgcolor=lightblue>Item number: " +
itemcount.ToString() + "</TD><TD>";
lc.DataBinding += new
EventHandler(TemplateControl_DataBinding);
break;
case ListItemType.Footer:
lc.Text = "</TABLE>";
break;
}
container.Controls.Add(lc);
itemcount += 1;
}
as you can see, the code dynamically adds a literal control to the item
template. can someone please help me add other controls like a button?
i would really like to add a table control and not have to use a
literal control to add the table control.
thanks for all your help.