信心在于我心

-----------------做个快乐的程序员。

导航

DataList控件嵌入gridview控件

Posted on 2009-03-17 09:16  程天程  阅读(410)  评论(0编辑  收藏  举报

    <asp:DataList ID="DataList2" runat="server" style="color:White" BackColor="White" Font-Bold="False"
            Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
            Font-Underline="False" BorderColor="#999999" BorderStyle="None"
            BorderWidth="1px" CellPadding="3" GridLines="Vertical">
        <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
        <AlternatingItemStyle BackColor="#DCDCDC" />
        <ItemStyle BackColor="#EEEEEE" ForeColor="Black" />
        <SelectedItemStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
        <HeaderTemplate>
            课程下载统计
        </HeaderTemplate>
        <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
    <ItemTemplate>
    <div style="height:25px; ">
    课程标题:<%#Eval("classTitle")%> 共下载次数:
    <%#Eval("countNum")%>
    </div>
    <div style="font-size:12px; font-weight:normal">
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
            AutoGenerateColumns="False"
            DataSource='<%# DLSdr(Eval("classID").ToString()) %>' PageSize="5"
            onpageindexchanging="GridView1_PageIndexChanging" ShowHeader="False"
            Width="100%">
            <FooterStyle Height="12px" />
            <Columns>
                <asp:TemplateField HeaderText="标题">
                 <ItemTemplate>
                  <%#Eval("classTitle") %>
                </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="IP">
                 <ItemTemplate>
                  <%#Eval("DownloadIP")%>
                </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="用户">
                 <ItemTemplate>
                  <%#Eval("userName")%>
                </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="下载时间">
                 <ItemTemplate>
                  <%#Eval("DownloadTime")%>
                </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
    </div>
    </ItemTemplate>
    </asp:DataList>

    public DataSet DLSdr(string strID)
    {
        Guid ID = new Guid(strID);
        string sqlSelect = "select classDownLoadID,(select classTitle from class where classID='" + ID + "') as classTitle,DownloadIP,userName,DownloadTime from Class_Download where classID='" + ID + "' order by DownloadTime desc";              
        return ngv.Getds(sqlSelect);
    }