html

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FileUploadDataSource.aspx.cs" Inherits="WebApplication1.FileUploadDataSource" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type ="text/css" >
        .fileList li{  margin-bottom :5px;}
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:FileUpload ID="upFile" runat="server" />
        <asp:Button ID="Button1" runat="server"
            Text="上传" onclick="Button1_Click" />
    </div>
    <div>
        <asp:Repeater ID="Repeater1" runat="server" DataSourceID="Sqldatasource1">
        <HeaderTemplate >
            <ul class ="fileList">
        </HeaderTemplate>
        <ItemTemplate >
            <li>
                <asp:HyperLink ID="HyperLink1" runat="server" Text ='<%#Eval("FileName")%>' NavigateUrl ='<%#Eval("Id","~/FileHandler.ashx?id={0}") %>'>HyperLink</asp:HyperLink> 
            </li>
        </ItemTemplate>
        <FooterTemplate >
            </ul>
        </FooterTemplate>
        </asp:Repeater>
    </div>
    <asp:sqldatasource ID="Sqldatasource1" runat="server" 
    ConnectionString="Data Source=localhost;Initial Catalog=test;Integrated Security=True" 
    ProviderName="System.Data.SqlClient" 
        
        InsertCommand="insert into Files(FileName,FileBytes)values(@FileName,@FileBytes)" 
        SelectCommand="SELECT Files.* FROM Files">
        <InsertParameters>
            <asp:ControlParameter ControlID="upFile" Name="FileName" 
                PropertyName="FileName" />
            <asp:ControlParameter ControlID ="upFile" Name ="FileBytes" PropertyName ="FileBytes" />
        </InsertParameters>
    </asp:sqldatasource>
    </form>
</body>
</html>
View Code

相关文章:

  • 2022-12-23
  • 2021-11-04
  • 2021-08-16
  • 2021-12-15
  • 2022-12-23
  • 2022-02-24
  • 2022-12-23
  • 2021-08-16
猜你喜欢
  • 2021-11-13
  • 2022-12-23
  • 2021-05-18
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案