2010-02-06 43 views
0

使用Asp.Net和08 C#,使用northwind數據庫。我想在GridView的細胞wcCategory.ascx文件使用在Gridview或detailsView單元格中使用wcCategory.ascx文件

下面我wcCategory.ascx文件

 <asp:ScriptManager ID="ScriptManager1" runat="server"> 
</asp:ScriptManager> 
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
<ContentTemplate> 

    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
<cc1:PopupControlExtender ID="TextBox1_PopupControlExtender" runat="server" 
    DynamicServicePath="" Enabled="True" ExtenderControlID="" PopupControlID="pnlPopeUp" 
    TargetControlID="TextBox1"> 
</cc1:PopupControlExtender> 

    <asp:Panel ID="pnlPopeUp" runat="server"> 
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
    DataKeyNames="CategoryID" DataSourceID="SqlDataSource1" 
      onselectedindexchanged="GridView1_SelectedIndexChanged"> 
    <Columns> 
     <asp:TemplateField HeaderText="CategoryID" InsertVisible="False" 
      SortExpression="CategoryID"> 
      <EditItemTemplate> 
       <asp:Label ID="Label1" runat="server" Text='<%# Eval("CategoryID") %>'></asp:Label> 
      </EditItemTemplate> 
      <ItemTemplate> 
       <asp:Label ID="lblCategoryID" runat="server" Text='<%# Bind("CategoryID") %>'></asp:Label> 
      </ItemTemplate> 
     </asp:TemplateField> 
     <asp:BoundField DataField="CategoryName" HeaderText="CategoryName" 
      SortExpression="CategoryName" /> 
     <asp:BoundField DataField="Description" HeaderText="Description" 
      SortExpression="Description" /> 
     <asp:CommandField ShowSelectButton="True" /> 
    </Columns> 
</asp:GridView> 
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" 
    SelectCommand="SELECT [CategoryID], [CategoryName], [Description] FROM [Categories]"> 
</asp:SqlDataSource> 
</asp:Panel> 



</ContentTemplate> 

</asp:UpdatePanel> 

貝婁是我的.aspx文件

<div> 

      <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
     DataKeyNames="ProductID" DataSourceID="SqlDataSource2"> 
     <Columns> 
      <asp:TemplateField HeaderText="ProductID" InsertVisible="False" 
       SortExpression="ProductID"> 
       <EditItemTemplate> 
        <asp:Label ID="Label1" runat="server" Text='<%# Eval("ProductID") %>'></asp:Label> 
       </EditItemTemplate> 
       <ItemTemplate> 
        <asp:Label ID="Label1" runat="server" Text='<%# Bind("ProductID") %>'></asp:Label> 
       </ItemTemplate> 
      </asp:TemplateField> 
      <asp:TemplateField HeaderText="ProductName" SortExpression="ProductName"> 
       <EditItemTemplate> 
        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ProductName") %>'></asp:TextBox> 
       </EditItemTemplate> 
       <ItemTemplate> 
        <asp:Label ID="Label2" runat="server" Text='<%# Bind("ProductName") %>'></asp:Label> 
       </ItemTemplate> 
      </asp:TemplateField> 
      <asp:TemplateField HeaderText="SupplierID" SortExpression="SupplierID"> 
       <EditItemTemplate> 
        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("SupplierID") %>'></asp:TextBox> 
       </EditItemTemplate> 
       <ItemTemplate> 
        <asp:Label ID="Label3" runat="server" Text='<%# Bind("SupplierID") %>'></asp:Label> 
       </ItemTemplate> 
      </asp:TemplateField> 
      <asp:TemplateField HeaderText="CategoryID" SortExpression="CategoryID"> 
       <EditItemTemplate> 
        <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("CategoryID") %>'></asp:TextBox> 
        <br /> 

        <br /> 
       </EditItemTemplate> 
      </asp:TemplateField> 
      <asp:TemplateField HeaderText="QuantityPerUnit" 
       SortExpression="QuantityPerUnit"> 
       <EditItemTemplate> 
        <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("QuantityPerUnit") %>'></asp:TextBox> 
       </EditItemTemplate> 
       <ItemTemplate> 
        <asp:Label ID="Label5" runat="server" Text='<%# Bind("QuantityPerUnit") %>'></asp:Label> 
       </ItemTemplate> 
      </asp:TemplateField> 
      <asp:CommandField ShowEditButton="True" /> 
     </Columns> 
    </asp:GridView> 
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
     ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" 
     SelectCommand="SELECT [ProductID], [ProductName], [SupplierID], [CategoryID], [QuantityPerUnit] FROM [Products]"> 
    </asp:SqlDataSource> 

     <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />  
    </div> 

我希望我的.ascx文件使用在gridview類別單元格

回答

0

使用佔位符和在rowdatabound使用findcontrol找到佔位符並使用loadcontrol添加您r usercontrol控制佔位符的控件集合。這有幫助嗎?

相關問題