1
<asp:HiddenField ID="hfOrderState" Value="1" runat="server" />
    <asp:SqlDataSource ID="ReadyOrders" runat="server" EnableCaching="true" 
                       DataSourceMode="DataSet" CacheDuration="20"
         ConnectionString="<%$ ConnectionStrings:XactCoffeeConnectionString %>" 
         SelectCommand="SELECT [Orders].* ,[Tables].table_name 
                        FROM [Orders] , [Tables]
                        WHERE order_state = @order_state
                        AND [Orders].table_id = [Tables].table_id">
         <SelectParameters>
            <asp:ControlParameter ControlID="hfOrderState" Name="order_state"
                                  PropertyName="Value" Type="Int32" />
         </SelectParameters>
    </asp:SqlDataSource>


<div id="xx" runat="server" class="sidePanel" 
    style="position: fixed; width: 57px; right: 0px; top: 15px; height: 100%; background-color: #00FF00; background-image: none;">
<p>
 جاهز     
 </p>

    <asp:Repeater ID="Repeater1" DataSourceID="ReadyOrders" runat="server">
    <ItemTemplate>
        <asp:HiddenField ID="OrderId" Value='<%# Eval("order_id") %>' runat="server"></asp:HiddenField>
        <asp:SqlDataSource ID="sqlOrderItems" runat="server"  
        EnableCaching="true" DataSourceMode="DataSet" CacheDuration="20" 
    ConnectionString="<%$ ConnectionStrings:XactCoffeeConnectionString %>" 
    SelectCommand="GetOrderItems" SelectCommandType="StoredProcedure">
    <SelectParameters>
        <asp:ControlParameter ControlID="OrderId" Name="order_id" 
            PropertyName="Value" Type="Int64" />
    </SelectParameters>
</asp:SqlDataSource>        
<br />

<table id="tbOrders"  visible="false">
<thead>
    <asp:HiddenField ID="hfOrderId" Value ='<%# Eval("order_id") %>'  runat="server" />
<asp:Button ID="Button1" CssClass ="OrderButton" OnClick="b_click" runat="server" Text='<%# Eval("table_name") %>' />
</thead>
<asp:Repeater ID="Repeater1" DataSourceID="sqlOrderItems" runat="server" >

    <ItemTemplate>
    <tr><td>
    <%# Eval("item_name") %>
    </td></tr>

    </ItemTemplate>
    </asp:Repeater>
    </table>

        <br />
  </ItemTemplate>
  </asp:Repeater>  

如何访问sqlDataSource被调用sqlOrderItems的子对象以便在 Button1 单击事件中重新绑定它?sqlDataSource我可以成功访问被调用的父级ReadyOrders,并且可以在后面的代码中调用ReadyOrders.DataBind();

另外我想说的是,被sqlDataSource调用的子对象sqlOrderItems取决于sqlDataSource被调用的父ReadyOrders对象,但显然在绑定父对象时,知道数据库中的数据已更改,页面中没有任何变化

4

0 回答 0