473,382 Members | 1,355 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

File list to DataGrid

I am getting a list of files from a folder in my website and it displays
fine.

But it is not putting the actual path into the file column.

My code is:

DirectoryInfo dirInfo = new
DirectoryInfo(Server.MapPath("/integration/ImportFile/"));
articleList.DataSource = dirInfo.GetFiles("*.txt");
articleList.DataBind();

It shows the correct files, but if I select the filename to display it - it
can't find it.

What I get is:

http://localhost/integration/EmployeeExtras.txt

It should be:

http://localhost/inetpub/wwwroot/int...oyeeExtras.txt

What am I doing wrong here? Doesn't MapPath work correctly? It does get
the correct files - just not the correct paths.

Thanks,

Tom
Sep 22 '06 #1
1 2397
"tshad" <ts**********@ftsolutions.comwrote in message
news:uq**************@TK2MSFTNGP05.phx.gbl...
>I am getting a list of files from a folder in my website and it displays
fine.

But it is not putting the actual path into the file column.

My code is:

DirectoryInfo dirInfo = new
DirectoryInfo(Server.MapPath("/integration/ImportFile/"));
articleList.DataSource = dirInfo.GetFiles("*.txt");
articleList.DataBind();

It shows the correct files, but if I select the filename to display it -
it can't find it.

What I get is:

http://localhost/integration/EmployeeExtras.txt

It should be:

http://localhost/inetpub/wwwroot/int...oyeeExtras.txt
In my Delete routine from the ItemDataBound event I can do this:

string fileName = (string)articleList.DataKeys[e.Item.ItemIndex];

This gives me the correct path as shown above.

But the first column (HyperLink column) does not get the correct path.

The DataGrid looks like:

<asp:datagrid id="articleList" runat="server" HeaderStyle-Font-Bold="True"
HeaderStyle-Font-Size="15pt"
HeaderStyle-ForeColor="White" HeaderStyle-BackColor="Navy"
AlternatingItemStyle-BackColor="#eeeeee"
AutoGenerateColumns="False" Font-Name="Verdana" DataKeyField="FullName"
OnItemDataBound="articleList_ItemDataBound"
OnDeleteCommand="articleList_DeleteFile">
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="Name" DataTextField="Name"
HeaderText="File Name" />
<asp:BoundColumn DataField="LastWriteTime" HeaderText="Last Write Time"
ItemStyle-HorizontalAlign="Center"
DataFormatString="{0:d}" />
<asp:BoundColumn DataField="Length" HeaderText="File Size"
ItemStyle-HorizontalAlign="Right" DataFormatString="{0:#,##0 bytes}" />
<asp:ButtonColumn Text="Delete" ButtonType="PushButton"
CommandName="Delete" />
</Columns>
</asp:datagrid>

Thanks,

Tom
What am I doing wrong here? Doesn't MapPath work correctly? It does get
the correct files - just not the correct paths.

Thanks,

Tom

Sep 22 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Muhammad Usman | last post by:
Respected Assistant I have table in a database named "student" having fields like name of student,Roll No and Status.The status is one of them absent,present or leave.The name and rollno field...
0
by: Mike Levin | last post by:
Hello Group, I'm using VisualStudio.NET and put a DataGrid into a WebUserControl (an ascx file). For the DataGrid element, I have set AllowSorting="True" and OnSortCommand="Grid_Sort".
1
by: Paul Wilson | last post by:
How do i display the list of files in a particular directory (only the file name), in a grid or similar control, with hyperlinks to be able to download those files. Regards, Paul
2
by: Eric Dan | last post by:
Hi, Even tough I was able to implement what I want in a weird and non efficient way, I would like to get an opinion what is the right way to achieve my task: Scenario: • Display a DataGrid...
3
by: Tom McLaughlin | last post by:
I am new to vb.net and I am running into problems understanding DataBinding and its concept. The only examples I find are always talk about Web design, I only want to use this data on my...
3
by: moondaddy | last post by:
I'm wanting to create a bindable list object made up of a list of business classes. I'm writing this in a vb.net 1.1 winforms app and am using a code example by Rocky Lhotka for reference...
2
by: Waran | last post by:
I Want to add a dropdown box in a datagrid on Page_Load. This Datagrid shares two tables. One table contains Employee details, and the other having the list of projects the employee is...
0
by: cindy | last post by:
I have a dynamic datagrid. I have custom classes for the controls public class CreateEditItemTemplateDDL : ITemplate { DataTable dtBind; string strddlName; string strSelectedID; string...
0
by: Anish G | last post by:
Hi All, I am getting the below given error while running my application in live server. In my local machine, its working fine. Please help me as it is very urgent for me. Exception from...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.