0

Web ユーザー コントロールを作成し、グリッドビューを更新パネル内に配置しました。このコントロールを Web フォームに追加しましたが、デザイン ビュー内にグリッドが表示されません。更新パネルの外にあるコントロールが表示されます。ブラウザーで表示するか、ユーザー コントロールから更新パネルを削除すると、すべて正常に動作します。

私のグリッドを表示する方法はありますか?デザイン ビューでグリッド コントロールの代わりに空白が表示されるのはわかりにくいです。

    <%@ 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>

製品.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 />

ここに画像の説明を入力

4

0 に答える 0