当前位置:编程学习 > C#/ASP.NET >>

DATALIST1和DATALIST2控制DATALIST3的问题

abc.aspx
---------------------------------------------------------------------

datalist1:


        <asp:DataList ID="DataList1" runat="server" CellPadding="4" DataSourceID="AccessDataSource1"
            ForeColor="#333333" OnItemCommand="DataList1_ItemCommand" RepeatDirection="Horizontal">
            <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
            <SelectedItemStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
            <ItemTemplate>
                <asp:LinkButton ID="LinkButton1" runat="server" CommandArgument='<%# Eval("levelid") %>'
                    CommandName="Show" Text='<%# Eval("level") %>'></asp:LinkButton>
            </ItemTemplate>
            <AlternatingItemStyle BackColor="White" />
            <ItemStyle BackColor="#E3EAEB" />
            <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
        </asp:DataList>


datalist2:

                <td style="width: 15%" valign="top">
                    <asp:DataList ID="DataList2" runat="server" CellPadding="4" DataKeyField="subid"
                        DataSourceID="AccessDataSource3" ForeColor="#333333" OnItemCommand="DataList2_ItemCommand">
                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <SelectedItemStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButton2" runat="server" CommandArgument='<%# Eval("subid") %>'
                                CommandName="Show" Text='<%# Eval("subname") %>'></asp:LinkButton>
                        </ItemTemplate>
                        <AlternatingItemStyle BackColor="White" ForeColor="#284775" />
                        <ItemStyle BackColor="#F7F6F3" ForeColor="#333333" />
                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    </asp:DataList>



datalist 3:

 <asp:DataList ID="DataList3" runat="server" CellPadding="4" DataSourceID="AccessDataSource4"
            ForeColor="#333333" OnItemCommand="DataList1_ItemCommand" Width="100%">
            <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
            <SelectedItemStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
            <ItemTemplate>
            <table width="98%" id="mindmap">
            <tr>
            <td width="50%" align="left"> <a href="<%# Eval("fileurl") %>"><asp:Label ID="filenameLabel" runat="server" Text='<%# Eval("filename") %>'></asp:Label></a></td>
            <td width="50%" align="left">                Filetype:
                <asp:Label ID="filetypeLabel" runat="server" Text='<%# Eval("filetype") %>'></asp:Label></td>
            </tr>
            <tr>
            <td colspan="2" align="left">               
                <asp:Label ID="filememoLabel" runat="server" Text='<%# Eval("filememo") %>'></asp:Label></td>
            </tr>
            <tr>
            <td align="left">Download:
                <asp:Label ID="downloadLabel" runat="server" Text='<%# Eval("download") %>'></asp:Label></td>
                <td align="left">Uploaded Time:
                <asp:Label ID="filetimeLabel" runat="server" Text='<%# Eval("filetime") %>'></asp:Label></td>
            </tr>
            </table>

            </ItemTemplate>
            <AlternatingItemStyle BackColor="White" />
            <ItemStyle BackColor="#E3EAEB" />
            <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
        </asp:DataList><asp:AccessDataSource ID="AccessDataSource4" runat="server" DataFile="~/mindmap.mdb"
          SelectCommand="SELECT [filename], [filememo], [download], [fileurl], [filetime], [filetype] FROM [file] ORDER BY [filetime] DESC">
      </asp:AccessDataSource>


============================================================
abc.aspx.cs

    protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName == "Show")
        {
            AccessDataSource2.SelectParameters["levelid"].DefaultValue = e.CommandArgument.ToString();
            AccessDataSource2.SelectCommand = "SELECT * FROM [file] WHERE [levelid] = " + AccessDataSource2.SelectParameters["levelid"].DefaultValue;
            //MyDataGrid.DataBind();
            DataList3.DataBind();
        }
    }
    protected void DataList2_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName == "Show")
        {
            AccessDataSource2.SelectParameters["subid"].DefaultValue = e.CommandArgument.ToString();
            AccessDataSource2.SelectCommand = "SELECT * FROM [file] WHERE [subid] = " + AccessDataSource2.SelectParameters["subid"].DefaultValue ;
            //MyDataGrid.DataBind();
            DataList3.DataBind();
        }
    }


有请高手帮忙,我主要是想让DATALIST1和DATALIST2控制DATALIST3的输出,点DATALIST1里的连接,DATALIST3就重新查询然后列出来,点DATALIST2,DATALIST3就重新查询然后列出来 --------------------编程问答-------------------- 问题要尽量提得简洁明确。并且你要调试之后,针对具体某几行代码问稍微深入一点的问题。 --------------------编程问答-------------------- 000000000000000000000
分!! --------------------编程问答-------------------- 代码没有问题,只是我做不出那效果
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,