2017-11-11 17 views
0

製品カテゴリを追加すると、detailviewは単独では更新されません。とにかくそれができますか?Asp.net Detailviewがリアルタイムで更新されない

Product Category

detailview

これはカテゴリ

<div class="container "style="background-color:lavender"> 
     <h2>Product Category </h2> 
<asp:DetailsView ID="DetailsViewCategory" runat="server" AutoGenerateRows="False" CellPadding="4" DataKeyNames="CategoryId" DataSourceID="SqlDataSourceCategory" DefaultMode="Insert" Height="83px" Width="360px" ForeColor="#333333" GridLines="None"> 
    <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> 
    <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" /> 
    <EditRowStyle BackColor="#999999" /> 
    <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" /> 
    <Fields> 
     <asp:BoundField DataField="CategoryId" HeaderText="CategoryId" InsertVisible="False" ReadOnly="True" SortExpression="CategoryId" /> 
     <asp:BoundField DataField="CategoryName" HeaderText="Category Name" SortExpression="CategoryName" /> 
     <asp:CommandField CancelText="" ShowInsertButton="True" /> 
    </Fields> 
    <FooterStyle BackColor="#5D7B9D" ForeColor="White" Font-Bold="True" /> 
    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> 
    <PagerStyle ForeColor="White" HorizontalAlign="Center" BackColor="#284775" /> 
    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> 
</asp:DetailsView> 
<br /> 
    </div> 

を追加するコードであり、これは私の詳細ビューのコード

<asp:DetailsView ID="DetailsViewProduct" runat="server" AutoGenerateRows="False" DataKeyNames="ProductId" DataSourceID="SqlDataSourceProduct" DefaultMode="Insert" Height="16px" Width="46%" OnItemInserted="InsertProduct" HorizontalAlign="Center"> 
    <Fields> 
     <asp:TemplateField HeaderText="Picture"> 
      <EditItemTemplate> 
       <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
      </EditItemTemplate> 
      <InsertItemTemplate> 
       <asp:FileUpload ID="FileUploadPicture" runat="server" Height="22px" Width="400px" CssClass="center-block" ForeColor="Black"/> 
      </InsertItemTemplate> 
      <ItemTemplate> 
       <asp:Image ID="Image1" runat="server" /> 
      </ItemTemplate> 
     </asp:TemplateField> 
     <asp:BoundField DataField="ProductId" HeaderText="ProductId" SortExpression="ProductId" InsertVisible="False" ReadOnly="True" /> 
     <asp:BoundField DataField="ProductName" HeaderText="Name" SortExpression="ProductName"/> 
     <asp:TemplateField HeaderText="Description" SortExpression="ProductDescription"> 
      <EditItemTemplate> 
       <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("ProductDescription") %>'></asp:TextBox> 
      </EditItemTemplate> 
      <InsertItemTemplate> 
       <asp:TextBox ID="TextBox2" runat="server" Height="42px" Text='<%# Bind("ProductDescription") %>' TextMode="MultiLine" Width="400px" CssClass="center-block"></asp:TextBox> 
      </InsertItemTemplate> 
      <ItemTemplate> 
       <asp:Label ID="Label1" runat="server" Text='<%# Bind("ProductDescription") %>'></asp:Label> 
      </ItemTemplate> 
     </asp:TemplateField> 
     <asp:TemplateField HeaderText="Category" SortExpression="ProductCategory"> 
      <EditItemTemplate> 
       <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("ProductCategory") %>'></asp:TextBox> 
      </EditItemTemplate> 
      <InsertItemTemplate> 
       <asp:SqlDataSource ID="SqlDataSourcePC" runat="server" ConnectionString="<%$ ConnectionStrings:DefaultConnection %>" SelectCommand="SELECT * FROM [ProductCategory]"></asp:SqlDataSource> 
       <asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="SqlDataSourcePC" DataTextField="CategoryName" DataValueField="CategoryId" Height="18px" SelectedValue='<%# Bind("ProductCategory") %>' Width="400px" CssClass="center-block"> 
       </asp:DropDownList> 
      </InsertItemTemplate> 
      <ItemTemplate> 
       <asp:Label ID="Label2" runat="server" Text='<%# Bind("ProductCategory") %>'></asp:Label> 
      </ItemTemplate> 
     </asp:TemplateField> 
     <asp:TemplateField HeaderText="Brand" SortExpression="ProductBrand"> 
      <EditItemTemplate> 
       <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("ProductBrand") %>'></asp:TextBox> 
      </EditItemTemplate> 
      <InsertItemTemplate> 
       <asp:SqlDataSource ID="SqlDataSourceBrand1" runat="server" ConnectionString="<%$ ConnectionStrings:DefaultConnection %>" SelectCommand="SELECT * FROM [ProductBrand]"></asp:SqlDataSource> 
       <asp:DropDownList ID="DropDownList6" runat="server" DataSourceID="SqlDataSourceBrand1" DataTextField="ProductBrand" DataValueField="BrandId" SelectedValue='<%# Bind("ProductBrand") %>' Width="400px" CssClass="center-block"> 
       </asp:DropDownList> 
      </InsertItemTemplate> 
      <ItemTemplate> 
       <asp:Label ID="Label3" runat="server" Text='<%# Bind("ProductBrand") %>'></asp:Label> 
      </ItemTemplate> 
     </asp:TemplateField> 
     <asp:BoundField DataField="ProductPrice" HeaderText="Price (RM)" SortExpression="ProductPrice" /> 
     <asp:BoundField DataField="ProductQty" HeaderText="Stock Quantity" SortExpression="ProductQty" /> 
     <asp:CommandField CancelText="" ShowInsertButton="True" /> 
    </Fields> 
</asp:DetailsView> 
+0

私たちにいくつかのコードとこれまで試みたことを見せてください。 – Pyves

+0

[もっと速い回答を得るために、どのような状況で私の質問に「緊急」や他の類似のフレーズを追加することができますか?](// meta.stackoverflow.com/q/326569) - 要約は、ボランティアに対処する理想的な方法であり、おそらく回答を得ることは非生産的です。これをあなたの質問に追加しないでください。 – halfer

+0

ナンセンスを追加してポストレングスの編集者の制限を故意に迂回させることは、完全には不十分ではないダウンボォートを引き寄せることができることは注目に値する。この警告が表示された場合は、ボランティア編集者に「:-)」の作業を追加するよりも、追加する可能性がある詳細を検討してください。 – halfer

答えて

1

はいデータコントロールが更新されませんでページをリロードする必要があるため自動的にデータバインディング。ページロードイベントでコントロールのDataBind()メソッドを呼び出します。

DetailsViewCategory.DataBind(); 
関連する問題