T
tshad
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.DataSource = dirInfo.GetFiles("*.txt")
articleList.DataBind()
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:LinkButton ID="DocumantName" Text='<%# Container.DataItem("Name")%>'
OnClick="SetName_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"
AutoGenerateColumns="False"
Font-Name="Verdana"
DataKeyField="FullName"
OnItemDataBound="articleList_ItemDataBound"
OnDeleteCommand="articleList_DeleteFile"
OnItemCommand="ItemCmd"
Width="500px" style="padding-left:2px;border-collapse:separate"
runat="server" >
<alternatingitemstyle BackColor="#FFFFFF"/>
<itemstyle BackColor="#E9E9E9" ForeColor="#0000FF"/>
<headerstyle CssClass="jay" BackColor="#000000" ForeColor="#FFFFFF"
Font-Bold="true" />
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="Name"
DataTextField="Name" HeaderText="File Name"></asp:HyperLinkColumn>
<asp:BoundColumn DataField="LastWriteTime" HeaderText="Last Write
Time" DataFormatString="{0:d}">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="Length" HeaderText="File Size"
DataFormatString="{0:#,##0 bytes}">
<ItemStyle HorizontalAlign="Right"></ItemStyle>
</asp:BoundColumn>
<asp:TemplateColumn HeaderText="DownLoad">
<ItemTemplate>
<asp:LinkButton id="DownLoad" Text="DownLoad" CommandName="Show"
Runat="server"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
<asp:ButtonColumn Text="Delete" ButtonType="PushButton"
HeaderText="Delete" CommandName="Delete"></asp:ButtonColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton ID="DocumantName" Text='<%#
Container.DataItem("Name")%>' OnClick="SetName_Click" runat="server"/>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
***********************************************************
Thanks,
Tom
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.DataSource = dirInfo.GetFiles("*.txt")
articleList.DataBind()
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:LinkButton ID="DocumantName" Text='<%# Container.DataItem("Name")%>'
OnClick="SetName_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"
AutoGenerateColumns="False"
Font-Name="Verdana"
DataKeyField="FullName"
OnItemDataBound="articleList_ItemDataBound"
OnDeleteCommand="articleList_DeleteFile"
OnItemCommand="ItemCmd"
Width="500px" style="padding-left:2px;border-collapse:separate"
runat="server" >
<alternatingitemstyle BackColor="#FFFFFF"/>
<itemstyle BackColor="#E9E9E9" ForeColor="#0000FF"/>
<headerstyle CssClass="jay" BackColor="#000000" ForeColor="#FFFFFF"
Font-Bold="true" />
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="Name"
DataTextField="Name" HeaderText="File Name"></asp:HyperLinkColumn>
<asp:BoundColumn DataField="LastWriteTime" HeaderText="Last Write
Time" DataFormatString="{0:d}">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="Length" HeaderText="File Size"
DataFormatString="{0:#,##0 bytes}">
<ItemStyle HorizontalAlign="Right"></ItemStyle>
</asp:BoundColumn>
<asp:TemplateColumn HeaderText="DownLoad">
<ItemTemplate>
<asp:LinkButton id="DownLoad" Text="DownLoad" CommandName="Show"
Runat="server"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
<asp:ButtonColumn Text="Delete" ButtonType="PushButton"
HeaderText="Delete" CommandName="Delete"></asp:ButtonColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton ID="DocumantName" Text='<%#
Container.DataItem("Name")%>' OnClick="SetName_Click" runat="server"/>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
***********************************************************
Thanks,
Tom