开发者

How could i get dynamic gridview in cs page

I am having list of gridviews with submit button created dynamically using GridViewTemplate class created. Whole things inserted in panel. No design in .aspx page like in class file

void ITemplate.InstantiateIn(System.Web.UI.Control container)
    {
        switch (_templateType)
        {
            case ListItemType.Header:

                Label lbl = new Label();            
                Label lbl1 = new Label();
                lbl1.DataBinding += new EventHandler(lbl_DataBinding);    
                lbl.DataBinding += new EventHandler(lbl1_DataBinding);

                container.Controls.Add(lbl);        
                container.Controls.Add(lbl1);       
                break;

in aspx script at runat="server"

GridView gv = new GridView();
TemplateField dataid= new TemplateField();

dataid.ItemTemplate = new GridViewTemplate(ListItemType.Header, "data1");

gv.Columns.Add(dataid);

gv.DataBind();

panel.Controls.Add(gv);

HtmlButton btn = new HtmlButton();

开发者_Go百科btn.ID="btn"+i.ToString()

panel.Controls.Add(btn);

Id:gridview1

Id:submit1

Id:gridview2

Id:submit2

How could i get the dynamic gridview on save click of button?


For Dynamic Controls I would Prefer DynamicControlsPlaceholder it will allows you to work with dynamically created controls, attaching events to them, finding controls etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜