Hi All,
I want to insert the upload files into the datalist. Only insert to the 9 files after that goes to next page, and is not working the upload button.
I insert the code:
HTML:
<asp:Label ID="document" runat="server" Text="Document">
| <asp:TextBox ID="name" runat="server" AutoPostBack="true">
|
<asp:Label ID="upload" runat="server" Text="Upload Document">
| <asp:FileUpload ID="FileUpload1" runat="server" multiple="true" Style="text-align: center;
margin-left: 50px;" Height="27px" />
|
<asp:Button ID="btnUpload" runat="server" Text="Upload" CommandName="Add" Style="margin-left: 200px;
margin-top: 30px; font-size: x-large; font-style: italic; color: Purple" />
<asp:Label ID="Label1" runat="server" ForeColor="Red">
<asp:DataList ID="datalist" runat="server" RepeatColumns="4" CellPadding="5" BorderWidth="25px"
CellSpacing="2" Font-Bold="True" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
Font-Underline="False" GridLines="Both">
<HeaderTemplate>
</HeaderTemplate>
<itemtemplate>
<footertemplate>
<input type="button" class="previous" id="btn1" value="<<Previous" />
<input type="button" class="next" id="btn2" value="Next>>" />
My Folder
|
<asp:TextBox ID="name" runat="server" Text='<%# Container.DataItem.ToString() %>'>
| <asp:LinkButton ID="lnkDownload" Text="Download" CommandArgument='<%# Eval("Value") %>'
runat="server" OnClick="DownloadFile" />
| <asp:LinkButton ID="lnkDelete" Text="Delete" CommandArgument='<%# Eval("Value") %>'
runat="server" OnClick="DeleteFile" />
|
</form>
</body>
</html>
VB.NET:
Dim lsfilename As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim filePaths() As String = Directory.GetFiles(Server.MapPath("..\Fileupload\insert\"))
Dim files As List(Of ListItem) = New List(Of ListItem)
For Each filePath As String In filePaths
files.Add(New ListItem(Path.GetFileName(filePath), filePath))
Next
datalist.DataSource = files
datalist.DataBind()
End If
End Sub
Protected Sub UploadFile(ByVal sender As Object, ByVal e As EventArgs)
Dim fileName As String = Path.GetFileName(FileUpload1.PostedFile.FileName)
FileUpload1.PostedFile.SaveAs((Server.MapPath("..\Fileupload\insert\") + name.Text))
lsfilename = name.Text
Response.Redirect(Request.Url.AbsoluteUri)
End Sub
End Class
Please any body help to me.
Thanks,