Gridview within a placeholder

369 Views Asked by At

i have currently create a user web control with a dataview in it currently this is the gridview

<div class="col-md-12">
        <asp:GridView id="dtgrid1" runat="server" AutoGenerateColumns="False"  AutoGenerateDeleteButton="True" AutoGenerateEditButton="True" AutoGenerateSelectButton="True" CellPadding="4" ForeColor="#333333" GridLines="Horizontal" AllowPaging="True" width="100%" ShowFooter="True" ShowHeaderWhenEmpty="True" EmptyDataText="No records Found">
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            <Columns>
                <asp:BoundField DataField="ID" HeaderText="ID" ItemStyle-Width="30" />
                <asp:BoundField DataField="Descripcion" HeaderText="Descripcion" ItemStyle-Width="250" />
                <asp:BoundField DataField="Monto" HeaderText="Monto" ItemStyle-Width="150" />
                <asp:BoundField DataField="Fecha" HeaderText="Fecha" ItemStyle-Width="150" />
            </Columns>
            <EditRowStyle BackColor="#999999" />
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#E9E7E2" />
            <SortedAscendingHeaderStyle BackColor="#506C8C" />
            <SortedDescendingCellStyle BackColor="#FFFDF8" />
            <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
        </asp:GridView>
    </div>

that gridview is in a webuser control with other cotrols and divs, everythings show as it should but the gridviews this is the code on the onload event

If Not Page.IsPostBack Then
            dim dgv1datatable as new DataTable
            With dgv1datatable
                .Columns.Add(New DataColumn("ID", GetType(Integer)))
                .Columns.Add(New DataColumn("Descripcion", GetType(String)))
                .Columns.Add(New DataColumn("Monto", GetType(Double)))
                .Columns.Add(New DataColumn("Fecha", GetType(Date)))
            End With
            Session("dgv1dt") = dgv1datatable
            dtgrid1.DataSource = DirectCast(Session("dgv1dt"), DataTable)
            dtgrid1.DataBind()
            dtgrid1.Visible = True
        End If

but it's now showing the gridview but if i insted place the gridview where the placeholder should be the gridview shows any help please?

EDIT im going to try and explain better the issue this is where the gridview should've within a webusercontrol that is in a placeholder enter image description here so since it wasn't showing i decided to delete the placeholder and place the gridview in the same place and it did appear enter image description here

1

There are 1 best solutions below

1
Ang Xiong Lin On
<asp:SqlDataSource ID="SqlDataSource1" runat="server" CacheExpirationPolicy="Sliding" 
    ConnectionString="<%$ ConnectionStrings:catalog %>"     
        SelectCommand="SELECT * FROM YourDB"></asp:SqlDataSource>