⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 newspublicl.ascx

📁 B/S asp.net的C#编的网站
💻 ASCX
字号:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="NewsPublicl.ascx.cs" Inherits="NewsPublicl" %>
<table style="width: 350px">
    <tr>
        <td align="left" style="width: 100px;" valign="top">
            <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                DataKeyNames="NewsID" DataSourceID="SqlDataSource1" EmptyDataText="没有可显示的数据记录。"
                OnSelectedIndexChanged="GridView1_SelectedIndexChanged" Width="475px" BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" ForeColor="Black" GridLines="Vertical">
                <Columns>
                    <asp:TemplateField HeaderText="新闻公告" SortExpression="Time">
                        <ItemTemplate>
                            <table style="width: 486px">
                                <tr>
                                    <td style="width: 330px; border-top-style: none; border-right-style: none; border-left-style: none;
                                        height: 21px; border-bottom-style: none">
                                        <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# "NewsContent.aspx?NewsID="+Eval("NewsID") %>'
                                            Text='<%# Eval("Title") %>'></asp:HyperLink></td>
                                    <td align="right" style="width: 100px;">
                                        <asp:Label ID="Label1" runat="server" Text='<%# Eval("Time", "{0:d}") %>'></asp:Label></td>
                                </tr>
                            </table>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <FooterStyle BackColor="#CCCCCC" />
                <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
                <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
                <AlternatingRowStyle BackColor="#CCCCCC" />
            </asp:GridView>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ACMConnectionString %>"
                DeleteCommand="DELETE FROM [News] WHERE [NewsID] = @NewsID" InsertCommand="INSERT INTO [News] ([Title], [Content], [Time]) VALUES (@Title, @Content, @Time)"
                ProviderName="<%$ ConnectionStrings:ACMConnectionString.ProviderName %>" SelectCommand="SELECT [NewsID], [Title], [Content], [Time] FROM [News] ORDER BY [Time] DESC"
                UpdateCommand="UPDATE [News] SET [Title] = @Title, [Content] = @Content, [Time] = @Time WHERE [NewsID] = @NewsID">
                <DeleteParameters>
                    <asp:Parameter Name="NewsID" Type="Int32" />
                </DeleteParameters>
                <UpdateParameters>
                    <asp:Parameter Name="Title" Type="String" />
                    <asp:Parameter Name="Content" Type="String" />
                    <asp:Parameter Name="Time" Type="DateTime" />
                    <asp:Parameter Name="NewsID" Type="Int32" />
                </UpdateParameters>
                <InsertParameters>
                    <asp:Parameter Name="Title" Type="String" />
                    <asp:Parameter Name="Content" Type="String" />
                    <asp:Parameter Name="Time" Type="DateTime" />
                </InsertParameters>
            </asp:SqlDataSource>
        </td>
    </tr>
</table>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -