DataBinding:'System.Data.DataRowView'不包含名为'Address'的属性 [英] DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Address'
问题描述
我一直在谷歌搜索2天。
我正在尝试在网页上获取网格视图,但它无法正常工作。我已经在这个网站上完成了数百次,从来没有问题。这不是SQLDataSource中缺少字段的问题。查询在configure datasource向导中运行正常。
这是gridview。我取出了其余的字段。
< asp:GridView ID = GridView1
runat = server
AllowPaging = True
AllowSorting = 真
AutoGenerateColumns = False
< span class =code-attribute>
PageSize = 200
GridLines = 垂直
CellPadding = 4
字体大小 = 中
CssClass = gridviewPageGRID
DataSourceID = SqlDataSource1
DataKeyNames = Address_Hash >
< 列 >
< asp:TemplateField HeaderText = 地址 SortExpression = 地址 >
< ItemTemplate >
< asp:标签 ID = l3 runat = server 文本 =' <% #Eval( 地址)%>' / >
< / ItemTemplate >
< / asp:TemplateField >
< /列 >
< / asp:GridView >
这是SQLDataSource:
SELECT < span class =code-keyword> CASE COALESCE (POBox,' ')
WHEN ' ' 那么
Street_Number
+ ' ' + Street_PreDir
+ ' ' + Street_Name
+ ' ' + Street_Suffix
+ ' ' + Street_PostDir
+ ' < br />' + City
+ ' ,' + State
+ ' ' + ZIP
ELSE
' 邮政信箱' + POBox
+ < span class =code-string>' < br />' + City
+ ' ,' +州
+ ' ' + ZIP
END AS 地址
FROM ERP.dbo.A_Address_Master
此SQL工作正常网站上的其他页面。返回的* only *字段是Address,为什么这次轰炸呢? SQL在Toad中工作,它适用于在VS中设置数据源,那么gridview有什么问题?
< ; asp:label runat = server id = lblGvPengumuman text = <% #Bind(地址 )%> > < / asp:label >
试试这个。
< asp:Label ID =Label3runat =serverText ='<%#Bind(Address)%>'CssClass =grid>< / asp:Label>
I've been searching Google for 2 days.
I'm trying to get a gridview on a page and it's just not working. I've done this hundreds of times on this site, never a problem. This is not a matter of a missing field in the SQLDataSource. The query runs fine in the "configure datasource" wizard.
Here is the gridview. I took out the rest of the fields.
<asp:GridView ID="GridView1"
runat="server"
AllowPaging="True"
AllowSorting="True"
AutoGenerateColumns="False"
PageSize="200"
GridLines="Vertical"
CellPadding="4"
Font-Size="Medium"
CssClass="gridviewPageGRID"
DataSourceID="SqlDataSource1"
DataKeyNames="Address_Hash">
<Columns>
<asp:TemplateField HeaderText="Address" SortExpression="Address">
<ItemTemplate>
<asp:Label ID="l3" runat="server" Text='<%# Eval("Address")%>'/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Here is the SQLDataSource:
SELECT CASE COALESCE(POBox,'')
WHEN '' THEN
Street_Number
+ ' ' + Street_PreDir
+ ' ' + Street_Name
+ ' ' + Street_Suffix
+ ' ' + Street_PostDir
+ '<br />' + City
+ ', ' + State
+ ' ' + ZIP
ELSE
'PO Box ' + POBox
+ '<br />' + City
+ ', ' + State
+ ' ' + ZIP
END AS Address
FROM ERP.dbo.A_Address_Master
This SQL has worked fine on other pages in the site. The *only* field returned is Address, so why is this bombing? The SQL works in Toad, it works in setting up the data source in VS, so what's wrong with the gridview?
<asp:label runat="server" id="lblGvPengumuman" text="<%# Bind("Address") %>" ></asp:label>
Try this.
<asp:Label ID="Label3" runat="server" Text='<%# Bind("Address") %>' CssClass="grid"></asp:Label>
这篇关于DataBinding:'System.Data.DataRowView'不包含名为'Address'的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!