473,804 Members | 3,037 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FileInfo not working in DataGrid

I am having a problem with my Datagrid that displays my Files via GetFiles()

If I use a HyperLinkColumn - I can use the column name "Name" which is what
the result from GetFiles().

*************** *************** *************** ***********
Sub GetFileList()
Dim dirInfo as DirectoryInfo = new
DirectoryInfo(S erver.MapPath("/uploads/"))

articleList.Dat aSource = dirInfo.GetFile s("*.txt")
articleList.Dat aBind()
End Sub
*************** *************** *************** *************** **

I added a LinkButton as I am having a problem with the HyperLinkColumn but
for some reason I am getting an error that says:

No default member found for type 'FileInfo'.

I am using the following LinkButton definition in my DataGrid:

<asp:LinkButt on ID="DocumantNam e" Text='<%# Container.DataI tem("Name")%>'
OnClick="SetNam e_Click" runat="server"/>

Am I not setting my Text attribute correctly? "Name" works for the
HyperLinkColumn , why not for the LinkButton?

Here is the whole DataGrid:
*************** *************** *************** *********
<asp:datagrid id="articleList "
AutoGenerateCol umns="False"
Font-Name="Verdana"
DataKeyField="F ullName"
OnItemDataBound ="articleList_I temDataBound"
OnDeleteCommand ="articleList_D eleteFile"
OnItemCommand=" ItemCmd"
Width="500px" style="padding-left:2px;border-collapse:separa te"
runat="server" >
<alternatingite mstyle BackColor="#FFF FFF"/>
<itemstyle BackColor="#E9E 9E9" ForeColor="#000 0FF"/>
<headerstyle CssClass="jay" BackColor="#000 000" ForeColor="#FFF FFF"
Font-Bold="true" />
<Columns>
<asp:HyperLinkC olumn DataNavigateUrl Field="Name"
DataTextField=" Name" HeaderText="Fil e Name"></asp:HyperLinkCo lumn>
<asp:BoundColum n DataField="Last WriteTime" HeaderText="Las t Write
Time" DataFormatStrin g="{0:d}">
<ItemStyle HorizontalAlign ="Center"></ItemStyle>
</asp:BoundColumn >
<asp:BoundColum n DataField="Leng th" HeaderText="Fil e Size"
DataFormatStrin g="{0:#,##0 bytes}">
<ItemStyle HorizontalAlign ="Right"></ItemStyle>
</asp:BoundColumn >
<asp:TemplateCo lumn HeaderText="Dow nLoad">
<ItemTemplate >
<asp:LinkButt on id="DownLoad" Text="DownLoad" CommandName="Sh ow"
Runat="server"> </asp:LinkButton>
</ItemTemplate>
</asp:TemplateCol umn>
<asp:ButtonColu mn Text="Delete" ButtonType="Pus hButton"
HeaderText="Del ete" CommandName="De lete"></asp:ButtonColum n>
<asp:TemplateCo lumn>
<ItemTemplate >
<asp:LinkButt on ID="DocumantNam e" Text='<%#
Container.DataI tem("Name")%>' OnClick="SetNam e_Click" runat="server"/>
</ItemTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:datagrid>
*************** *************** *************** **************

Thanks,

Tom
Nov 6 '06 #1
2 1673
Have you tried using:
<%# DataBinder.Eval (Container.Data Item, "Name") %>

or, if you're in 2.0, just:

<%# Eval("Name") %>

or...

<%# ctype(Container .DataItem, FileInfo).Name %>

Karl
--
http://www.openmymind.net/
http://www.codebetter.com/
"tshad" <ts**********@f tsolutions.comw rote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>I am having a problem with my Datagrid that displays my Files via
GetFiles()

If I use a HyperLinkColumn - I can use the column name "Name" which is
what the result from GetFiles().

*************** *************** *************** ***********
Sub GetFileList()
Dim dirInfo as DirectoryInfo = new
DirectoryInfo(S erver.MapPath("/uploads/"))

articleList.Dat aSource = dirInfo.GetFile s("*.txt")
articleList.Dat aBind()
End Sub
*************** *************** *************** *************** **

I added a LinkButton as I am having a problem with the HyperLinkColumn but
for some reason I am getting an error that says:

No default member found for type 'FileInfo'.

I am using the following LinkButton definition in my DataGrid:

<asp:LinkButt on ID="DocumantNam e" Text='<%# Container.DataI tem("Name")%>'
OnClick="SetNam e_Click" runat="server"/>

Am I not setting my Text attribute correctly? "Name" works for the
HyperLinkColumn , why not for the LinkButton?

Here is the whole DataGrid:
*************** *************** *************** *********
<asp:datagrid id="articleList "
AutoGenerateCol umns="False"
Font-Name="Verdana"
DataKeyField="F ullName"
OnItemDataBound ="articleList_I temDataBound"
OnDeleteCommand ="articleList_D eleteFile"
OnItemCommand=" ItemCmd"
Width="500px" style="padding-left:2px;border-collapse:separa te"
runat="server" >
<alternatingite mstyle BackColor="#FFF FFF"/>
<itemstyle BackColor="#E9E 9E9" ForeColor="#000 0FF"/>
<headerstyle CssClass="jay" BackColor="#000 000" ForeColor="#FFF FFF"
Font-Bold="true" />
<Columns>
<asp:HyperLinkC olumn DataNavigateUrl Field="Name"
DataTextField=" Name" HeaderText="Fil e Name"></asp:HyperLinkCo lumn>
<asp:BoundColum n DataField="Last WriteTime" HeaderText="Las t Write
Time" DataFormatStrin g="{0:d}">
<ItemStyle HorizontalAlign ="Center"></ItemStyle>
</asp:BoundColumn >
<asp:BoundColum n DataField="Leng th" HeaderText="Fil e Size"
DataFormatStrin g="{0:#,##0 bytes}">
<ItemStyle HorizontalAlign ="Right"></ItemStyle>
</asp:BoundColumn >
<asp:TemplateCo lumn HeaderText="Dow nLoad">
<ItemTemplate >
<asp:LinkButt on id="DownLoad" Text="DownLoad" CommandName="Sh ow"
Runat="server"> </asp:LinkButton>
</ItemTemplate>
</asp:TemplateCol umn>
<asp:ButtonColu mn Text="Delete" ButtonType="Pus hButton"
HeaderText="Del ete" CommandName="De lete"></asp:ButtonColum n>
<asp:TemplateCo lumn>
<ItemTemplate >
<asp:LinkButt on ID="DocumantNam e" Text='<%#
Container.DataI tem("Name")%>' OnClick="SetNam e_Click" runat="server"/>
</ItemTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:datagrid>
*************** *************** *************** **************

Thanks,

Tom


Nov 7 '06 #2
"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
netwrote in message news:uU******** ******@TK2MSFTN GP04.phx.gbl...
Have you tried using:
<%# DataBinder.Eval (Container.Data Item, "Name") %>
Yes, and it works. Why don't I have to do the same in the HyperLinkColumn ?

I also have to do the same thing with HyperLink as I do with LinkButton (as
you suggested).

Thanks,

Tom
>
or, if you're in 2.0, just:

<%# Eval("Name") %>

or...

<%# ctype(Container .DataItem, FileInfo).Name %>

Karl
--
http://www.openmymind.net/
http://www.codebetter.com/
"tshad" <ts**********@f tsolutions.comw rote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>>I am having a problem with my Datagrid that displays my Files via
GetFiles()

If I use a HyperLinkColumn - I can use the column name "Name" which is
what the result from GetFiles().

************** *************** *************** ************
Sub GetFileList()
Dim dirInfo as DirectoryInfo = new
DirectoryInfo( Server.MapPath( "/uploads/"))

articleList.Dat aSource = dirInfo.GetFile s("*.txt")
articleList.Dat aBind()
End Sub
************** *************** *************** *************** ***

I added a LinkButton as I am having a problem with the HyperLinkColumn
but for some reason I am getting an error that says:

No default member found for type 'FileInfo'.

I am using the following LinkButton definition in my DataGrid:

<asp:LinkButto n ID="DocumantNam e" Text='<%# Container.DataI tem("Name")%>'
OnClick="SetNa me_Click" runat="server"/>

Am I not setting my Text attribute correctly? "Name" works for the
HyperLinkColum n, why not for the LinkButton?

Here is the whole DataGrid:
************** *************** *************** **********
<asp:datagri d id="articleList "
AutoGenerateCol umns="False"
Font-Name="Verdana"
DataKeyField="F ullName"
OnItemDataBound ="articleList_I temDataBound"
OnDeleteCommand ="articleList_D eleteFile"
OnItemCommand=" ItemCmd"
Width="500px" style="padding-left:2px;border-collapse:separa te"
runat="server" >
<alternatingite mstyle BackColor="#FFF FFF"/>
<itemstyle BackColor="#E9E 9E9" ForeColor="#000 0FF"/>
<headerstyle CssClass="jay" BackColor="#000 000"
ForeColor="#FF FFFF" Font-Bold="true" />
<Columns>
<asp:HyperLinkC olumn DataNavigateUrl Field="Name"
DataTextField= "Name" HeaderText="Fil e Name"></asp:HyperLinkCo lumn>
<asp:BoundColum n DataField="Last WriteTime" HeaderText="Las t Write
Time" DataFormatStrin g="{0:d}">
<ItemStyle HorizontalAlign ="Center"></ItemStyle>
</asp:BoundColumn >
<asp:BoundColum n DataField="Leng th" HeaderText="Fil e Size"
DataFormatStri ng="{0:#,##0 bytes}">
<ItemStyle HorizontalAlign ="Right"></ItemStyle>
</asp:BoundColumn >
<asp:TemplateCo lumn HeaderText="Dow nLoad">
<ItemTemplate >
<asp:LinkButt on id="DownLoad" Text="DownLoad"
CommandName="S how" Runat="server"> </asp:LinkButton>
</ItemTemplate>
</asp:TemplateCol umn>
<asp:ButtonColu mn Text="Delete" ButtonType="Pus hButton"
HeaderText="De lete" CommandName="De lete"></asp:ButtonColum n>
<asp:TemplateCo lumn>
<ItemTemplate >
<asp:LinkButt on ID="DocumantNam e" Text='<%#
Container.Data Item("Name")%>' OnClick="SetNam e_Click" runat="server"/>
</ItemTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:datagrid>
************** *************** *************** ***************

Thanks,

Tom



Nov 7 '06 #3

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

Similar topics

2
2513
by: John Bowman | last post by:
Hi All, ..NET 1.1... I'm wondering if there is any approach more convenient to get a list of FileInfo objects than the following. For example, if I wanted to get 1 list of all the Exe's and all the Dll's and all the Txt's in a folder, if appears I need to do something like the following: ArrayList InterestingFiles = new ArrayList(); DirectoryInfo di = new DirectoryInfo(@"C:\My Folder");
0
955
by: Craig Douglas | last post by:
Hello, does anyone have a good way of ordering a FileInfo collection in order that I can present it in a datagrid, or alternatively sort it within the datagrid? Thanks Craig
1
1504
by: Antonio | last post by:
Good morning, I've the following file system : C: -> HTML -> Aziende -> Azienda_1 -> a.jpg -> Azienda_2 -> a.jpg ... -> Azienda_N -> a.jpg my desire is to create an array of fileinfo containing the a.jpg , a.jpg , ... , a.jpg
0
944
by: Sosh | last post by:
Hi, Can someone tell me how to bind a FileInfo to a DataGrid. At the moment I am using something along the lines of someDataGrid.DataSource = someFileInfo; But am getting System.ArgumentOutOfRangeException on a parameter called index (not mine). The length of the FileInfo is 2 by the way.
5
6545
by: Lance | last post by:
I want to expose properties of a class to a user via a PropertyGrid class. Some of the properties are of type System.IO.FileInfo. Ideally, an OpenFileDialog window would appear when the user attempted to edit the value of the System.IO.FileInfo properties. Is there an existing UITypeEditor that will do this type of thing, or will I need to create my own Thanks Lance
1
1802
by: Benjamin | last post by:
I am trying to make a file I created a hidden file. I think I need to use the setfileattribute() but I cannot find it anywhere. I found this on msdn: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcedata5/html/wce50lrfsetfileattributes.asp can anyone direct me in the right direction?
1
2592
by: Tim Failes | last post by:
This seems a trival question, but I cannot get it to work properly... Essentially my question is, how can I create a text file, and guarantee it is given the current date/time as the Creation Time? My code is creating a file correctly, but the CreationTime is (sometimes) set to the CreationTime of an old file that has previously been removed. The line of code creating the file is _LogFileWriter = newFile.CreateText()
3
2173
by: rn5a | last post by:
To work with files, when should one use the File class & when should one use the FileInfo class? Similarly, to work with directories, when should one use the Directory class & when should one use the DirectoryInfo class?
5
6148
by: Tom P. | last post by:
I am having the following problem: I create a FileSystemWatcher and wait for events. When the event does happen I refresh a FileSystemInfo list and set properties accordingly (IsFile, IsDir, ReadOnly, etc.). The problem I'm having is in identifying when a FileSystemInfo entry is a FileInfo or a DirectoryInfo type. I get the rare, and yet oddly common, "setup.inf" file that for some inexplicable reason passes the standard...
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10326
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10075
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9143
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6851
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.