Hey guys & gals.
I'm having trouble trying to merge data into one dataset from an XML, and also from DirectoryInfo. The problem is I get this error "DataBinding: 'System.IO.FileInfo' does not contain a property with the name 'aid'". 'aid' is one of the nodes in my XML file. I would like to have it and a few other columns in the datagrid from both datasources.
I think the problem is when I try to put the DirectoryInfo() properties into a dataset using the instance.Equals method. I don't get an error during compliation, but the data is still not merging together... or is it. Is there something I neglected to do?
Dishon Gillis
Dominion Enterprises Company
I'm having trouble trying to merge data into one dataset from an XML, and also from DirectoryInfo. The problem is I get this error "DataBinding: 'System.IO.FileInfo' does not contain a property with the name 'aid'". 'aid' is one of the nodes in my XML file. I would like to have it and a few other columns in the datagrid from both datasources.
I think the problem is when I try to put the DirectoryInfo() properties into a dataset using the instance.Equals method. I don't get an error during compliation, but the data is still not merging together... or is it. Is there something I neglected to do?
Code:
<%@ Page Language="VB" Debug="true" %>
<script runat="server">
sub Page_Load(sender as Object, E as EventArgs)
If NOT IsPostBack Then
LoadFileList
End if
End sub
sub LoadFileList
Dim objdata1 as New DataSet()
objdata1.ReadXML(Server.Mappath("/APP_DATA/Photos.xml"))
datagrid2.Datasource = objdata1
Dim dirInfo as New DirectoryInfo(Server.MapPath("/PHOTOS/"))
Dim objdata2 as New DataSet()
objdata2.Equals(dirInfo)
datagrid2.DataSource = dirInfo.GetFiles("*.jpg")
Dim keepSchema As Boolean
keepSchema = True
objdata1.merge(objdata2, keepSchema)
datagrid2.DataBind()
End sub
Private lastVarValue as Integer
Function showval(a as integer)
lastVarValue = a
Return a
End Function
Code:
<asp:datagrid id="datagrid2" runat="server" Font-Size="8pt" Font-Name="verdana" Cellpadding="3" AutoGenerateColumns="False" ShowFooter="False" DataKeyField="aid" BorderWidth="1px" BorderColor="#DEBA84" BackColor="#DEBA84" Font-Names="verdana" BorderStyle="None" CellSpacing="2">
<Columns>
<asp:TemplateColumn HeaderText="Id">
<ItemTemplate>
<%# showval(DataBinder.Eval(Container.DataItem,"aid")) %>
</ItemTemplate>
<FooterTemplate>
<asp:Textbox runat="server" id="aid_add" Text='<%# int32.parse(lastVarValue)+1 %>' Columns="2" />
</FooterTemplate>
</asp:TemplateColumn>
<asp:HyperLinkColumn DataNavigateUrlField="FullName" 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:#,### bytes}" />
</Columns>
</asp:DataGrid>
Dishon Gillis
Dominion Enterprises Company