我目前正在创建一个带有数据视图的用户Web控件 目前这是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>
gridview是一个webuser控件与其他cotrols和divs,everythings显示它应该但gridview 这是onload事件上的代码
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
但它现在显示了gridview,但是如果我把它放在gridview应该是gridview的地方,那么gridview会显示任何帮助吗?
EDIT 我将尝试更好地解释这个问题 这是gridview应该在占位符中的webusercontrol中的位置 因为它没有显示我决定删除占位符并将gridview放在同一个地方它确实出现了
答案 0 :(得分:0)
<asp:SqlDataSource ID="SqlDataSource1" runat="server" CacheExpirationPolicy="Sliding"
ConnectionString="<%$ ConnectionStrings:catalog %>"
SelectCommand="SELECT * FROM YourDB"></asp:SqlDataSource>