急!!!GridView动态生成模版列的问题?
在page_load的事件中动态添加模版列:
public class GridViewTemplate : ITemplate
{
ListItemType templateType;
string columnName;
public GridViewTemplate(ListItemType type, string colname)
{
templateType = type;
columnName = colname;
}
public void InstantiateIn(System.Web.UI.Control container)
{
switch (templateType)
{
case ListItemType.Header:
//lc.Text = " <B> " + columnName + " </B> ";
//container.Controls.Add(lc);
break;
case ListItemType.Item:
DropDownList drr = new DropDownList();
drr.ID = "dropdown ";
drr.AppendDataBoundItems = true;
drr.Items.Add(new ListItem( "-----请选择------ ", " "));
drr.Items.Add(new ListItem( "AA ", "a "));
drr.Items.Add(new ListItem( "BB ", "b "));
drr.Items.Add(new ListItem( "CC ", "c "));