Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to bind gridview inside a repeater?

I want to bind gridview which is inside a repeater. My code is

 <asp:Repeater ID="rep_UnAssignComps" runat="server">

         <ItemTemplate>
            <asp:GridView ID="rep_DataSimilarToBacthid" runat="server" Style="text-align: center;
                width: 375px;" AutoGenerateColumns="false">
                <Columns>
                    <asp:BoundField HeaderText="Test" DataField="Test" />
                </Columns>

            </asp:GridView>

    </ItemTemplate>
</asp:Repeater>
like image 257
Ram Singh Avatar asked Sep 13 '11 06:09

Ram Singh


1 Answers

you have to fire repeater's ItemDataBound event. In which you have to find gridview then bind it as following:-

    If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then


        Dim grd As GridView = TryCast(e.Item.FindControl("rep_DataSimilarToBacthid"), GridView)
        grd.DataSource = dt

        grd.DataBind()
   end if 
like image 194
Ram Singh Avatar answered Oct 07 '22 09:10

Ram Singh