使用更新面板后,Web用户控件内的Gridview在设计视图中不可见

时间:2013-03-21 11:44:37

标签: asp.net visual-studio-2010 updatepanel webusercontrol

我创建了一个Web用户控件&在更新面板中放置了gridview。我将此控件添加到我的webform中,但是我无法在设计视图中看到网格。我只看到更新面板之外的控件。当我在浏览器中查看它或从用户控件中删除更新面板时,一切正常。

有什么东西要显示我的网格吗?在设计视图中看到空格而不是网格控件令人困惑。

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl.aspx.cs" Inherits="TestWebsite.WebUserControl" %>

<%@ Register src="Controls/Products.ascx" tagname="Products" tagprefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

        <uc1:Products ID="Products1" runat="server" />

    </div>
    </form>
</body>
</html>

Product.ascx

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Products.ascx.cs" Inherits="TestWebsite.Controls.Products" %>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="upnlProducts" runat="server" UpdateMode="Conditional" >
<ContentTemplate>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="ProductID" DataSourceID="SqlDataSource1">
        <Columns>
            <asp:BoundField DataField="ProductID" HeaderText="ProductID" 
                InsertVisible="False" ReadOnly="True" SortExpression="ProductID" />
            <asp:BoundField DataField="ProductName" HeaderText="ProductName" 
                SortExpression="ProductName" />
            <asp:BoundField DataField="SupplierID" HeaderText="SupplierID" 
                SortExpression="SupplierID" />
            <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" 
                SortExpression="CategoryID" />
            <asp:BoundField DataField="QuantityPerUnit" HeaderText="QuantityPerUnit" 
                SortExpression="QuantityPerUnit" />
            <asp:BoundField DataField="UnitPrice" HeaderText="UnitPrice" 
                SortExpression="UnitPrice" />
            <asp:BoundField DataField="UnitsInStock" HeaderText="UnitsInStock" 
                SortExpression="UnitsInStock" />
            <asp:BoundField DataField="UnitsOnOrder" HeaderText="UnitsOnOrder" 
                SortExpression="UnitsOnOrder" />
            <asp:BoundField DataField="ReorderLevel" HeaderText="ReorderLevel" 
                SortExpression="ReorderLevel" />
            <asp:CheckBoxField DataField="Discontinued" HeaderText="Discontinued" 
                SortExpression="Discontinued" />
            <asp:BoundField DataField="CategoryName" HeaderText="CategoryName" 
                SortExpression="CategoryName" />
        </Columns>
    </asp:GridView>
    </ContentTemplate>
    </asp:UpdatePanel>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" 
        SelectCommand="SELECT * FROM [Alphabetical list of products]">
    </asp:SqlDataSource>
    <br />

enter image description here

0 个答案:

没有答案