How to dynamically bind asp.net repeater control to datasource

前端 未结 5 557
情话喂你
情话喂你 2021-01-21 06:22

I have a page with a simple dropdown and repeater control in page.on submit repeater control is bound to datasource1 which has 3 columns.

5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-21 07:15

    With bootstrap and datatables.net plugins

    protected void rptReport_ItemDataBound(object sender, RepeaterItemEventArgs e)
            {
                if (e.Item.ItemType == ListItemType.Header)
                {
                    Repeater headerRepeater = e.Item.FindControl("Header1") as Repeater;
                    headerRepeater.DataSource = dtOrder.Columns;
                    headerRepeater.DataBind();
                }
    
                if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                {
                    Repeater columnRepeater = e.Item.FindControl("Item1") as Repeater;
                    var row = e.Item.DataItem as System.Data.DataRowView;
                    columnRepeater.DataSource = row.Row.ItemArray;
                    columnRepeater.DataBind();
                }
            }
    
    
        
    
        
    Sonuçlar
    <%# Container.DataItem %>
    <%# Container.DataItem %>

提交回复
热议问题