0

我想在一个列表视图中使用多个查询。在我的列表视图中,每一列的值都必须来自两个以上的表。那么我如何在列表视图中使用多个查询。

我的 asp.net 代码;

     <LayoutTemplate>
                        <table id="Table1" border="2" cellspacing="3" cellpadding="3" style="color: Black; border-bottom:1px solid black; border-right:1px solid black; border: thin solid #000000;" runat="server" >
                            <tr id="Tr1" runat="server">
                                <td id="Td1" runat="server">Owned By &nbsp;&nbsp;&nbsp;</td>
                                <td id="Td2" runat="server">Shared class &nbsp;&nbsp;&nbsp;</td>
                                <td id="Td3" runat="server">Effective Interest &nbsp;&nbsp;</td>
                                <td id="Td4" runat="server">Deemed Interest &nbsp;&nbsp;&nbsp;</td>
                                <td id="Td5" runat="server">Shares Owned &nbsp;&nbsp;&nbsp;</td>
                                <td id="Td12" runat="server">Shares Issued &nbsp;&nbsp;&nbsp;</td>
                            </tr>

                             <tr style="border-style: 1; border-color: #FFFFFF!important; border-width: 1px; color: #FF0000;">
                            <td><%#Eval("owner_CompanyId")%>&nbsp;</td>
                            <td><%#Eval("owner_sharetype")%>&nbsp;</td>
                            <td><%#Eval("owner_effectinterest")%>&nbsp;</td>   
                            <td><%#Eval("owner_effectinterest")%>&nbsp;</td>                 
                            <td><%#Eval("owner_shares")%>&nbsp;</td> 
                            </tr>


                            <tr id="ItemPlaceholder" runat="server">
                            </tr>
                        </table>
    <table>
    <tr style="border-style: 1; border-color: #FFFFFF!important; border-width: 1px; color: #FF0000;">
here i want to use the data from another tables with different queries
                            <td><%#Eval("comp_CompanyId")%>&nbsp;</td>
                            <td><%#Eval("ownercompanylog_sharetype")%>&nbsp;</td>
                            <td><%#Eval("owner_effectinterest")%>&nbsp;</td>   
                            <td><%#Eval("owner_effectinterest")%>&nbsp;</td>                 
                            <td><%#Eval("owner_shares")%>&nbsp;</td> 
                            </tr>
    </table>
                 </LayoutTemplate>

        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                 ConnectionString="<%$ ConnectionStrings:DreamsConnectionString4 %>" 

                 SelectCommand="SELECT [owner_CompanyId], [owner_childcompid], [owner_effectinterest], [owner_sharetype], [owner_shares] FROM [Owner] WHERE ([owner_CompanyId] = @owner_CompanyId)" 
                 OnSelecting="SqlDataSource1_Selecting" >

                <SelectParameters>
                    <asp:ControlParameter ControlID="HiddenField1" DefaultValue="18" 
                        Name="owner_CompanyId" PropertyName="Value" Type="Int32" />
                </SelectParameters>
             </asp:SqlDataSource>    
4

1 回答 1

1

您可以使用 UNION 语句并将两个结果连接在一起,每列的数据类型需要相同,因此您可能需要用额外的列填充一个查询以匹配另一个。

于 2012-05-24T07:57:32.407 回答