博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[转] --- Error: “A field or property with the name was not found on the selected data source” ge...
阅读量:6956 次
发布时间:2019-06-27

本文共 5663 字,大约阅读时间需要 18 分钟。

Error: “A field or property with the name was not found on the selected data source” get only on server

up vote

4
down vote
favorite
2
I publish my project without any warning on local iis and it works correctly (localhost/[myprojectName]). so, i upload them to server with cute ftp. but in server i get this error apear for all my filed like [tableName].[filedName]:

A field or property with the name 'ConfirmStatuse.Name' was not found on the selected data source

here's my code:

<asp:GridView ID="ordergv" runat="server" DataKeyNames="Id" AutoGenerateColumns="False" DataSourceID="SummaryOfOrderSrc" AllowSorting="True">

<Columns>
<asp:CommandField SelectText="select" ShowSelectButton="True" ButtonType="Button"/>
<asp:BoundField DataField="OrderId" />
<asp:BoundField DataField="ConfirmStatuse.Name" />
<asp:BoundField DataField="OrderStatuse.Name"/>
<asp:BoundField DataField="PaymentStatuse.Name"/>
<asp:BoundField DataField="ShipmentStatuse.Name" />
<asp:TemplateField >
<ItemTemplate>
<asp:Label ID="CreatedDateLabel" runat="server" Text='<%# GetPersianDate( Eval("CreatedDate")) %>' /></ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

<asp:LinqDataSource ID="SummaryOfOrderSrc" runat="server" ContextTypeName="Ahooratech.DAL.DataClasses1DataContext" EntityTypeName="" OrderBy="CreatedDate desc" TableName="Orders">

</asp:LinqDataSource>
I check the size of my project in local iis and on server. both of them are same(8,459,009 bytes)

so it means i use same database and same files for run my application for run on local and server. so why i get this error only in server?

The only difference here is on version of iis, i think my server iis version is 7.0. but is it important for i get this error?!!! i don't think so. i'm really confused.

(My local project and server project use same connection string).

EDIT: I publish project on another host and it works! but it doesn't work on my original server yet.

asp.net .net-4.0 iis-7.5 sql-server-2012

shareimprove this question
edited Jun 15 '13 at 6:26

asked Jun 15 '13 at 5:30

Mohammadreza

97441434
Resulting LINQ query object doesn't have the property given. What exactly is not clear for you? Error message is pretty straight forward. – abatishchev Jun 15 '13 at 5:39
1
hi dear, I have that property in my result query. error message is pretty clear but why it work on local but not work on server. I check the all things. all thing are same. @abatishchev – Mohammadreza Jun 15 '13 at 5:46
Okay, I see. Hmm. Maybe you have a silly but hidden mistake in deployment: are you sure you've copied the app properly and assemblies weren't cached? Double check. And try to delete Temp ASP.NET Files folder. – abatishchev Jun 15 '13 at 5:51
yes. i also delete all of them files and publish them. they are exactly same is size, even in bytes 8,459,009 bytes. i'm really confused @abatishchev . what thing can i ask or search for this error ?! – Mohammadreza Jun 15 '13 at 6:04
1
I too am having this issue. I have complete control over both my local and the web server environments and have assured that code/database are all identical. This definitely seems to be a version issue. – John Bledsoe Sep 26 '13 at 20:50
show 4 more comments
2 Answers
activeoldestvotes
up vote
6
down vote
This is the same issue to the one described here - Binding to Navigation Property causes " A field or property with the name 'X.X' was not found on the selected data source" in IIS 6 ONLY

It appears to be an issue with the BoundField control element. As suggested in an answer provided by user Anant in the article linked above, you can convert the BoundField to a TemplateField and it will work (using "OrderStatuse.Name" in your example). That solution worked for me.

Although this really doesn't explain why IIS6 can't support the BoundField in this way.

Mind boggling.

shareimprove this answer

answered Feb 6 '14 at 15:40

JamesHough

6113
thank you so much – Mohammadreza Feb 8 '14 at 6:19
add a comment

Did you find this question interesting? Try our newsletter

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

email address
Subscribe
up vote
2
down vote
accepted
I found the IIS Version on my server is 6. but my local is 7.5. I publish my project on another server with iis 7.5 and it works

Solution1: I create a summaryOfOrder like this:

class summaryOfOrder

{
public int Id { get; set; }
public int OrderId { get; set; }
public string ConfirmStatusName { get; set; }
public string OrderStatusName { get; set; }
public string PaymentStatusName { get; set; }
public string ShippingStatusName { get; set; }
public string CreatedDate { get; set; }

}
and change

<asp:BoundField DataField="ConfirmStatuse.Name" />

to

<asp:BoundField DataField="ConfirmStatusName" />

and bind class to grid by

gv.datasource = mySummryOfOrder;

gv.databind();
and initialize a list of this type and bind it to grid programmatically

Update solution 2 convert

asp:BoundField

to

asp:TemplateField and using

<%# Eval("Worker.FullName")%>

shareimprove this answer
edited Aug 26 at 18:35

Seva Alekseyev

36.3k1379172
answered Jun 15 '13 at 6:58

Mohammadreza

97441434
That got it working after trying for long time ! But don't know why issue was occurring after deployed on different server, it was working correctly with boundfield on my local. Is it because I have .NET 4.5 on my machine which has EF 6 where as deployment server had .NET 4 and probably with EF6 ? – Altaf Patel Sep 10 '14 at 10:27
I'm not sure but think it's because of IIS.@AltafPatel – Mohammadreza Sep 15 '14 at 2:23
Both machines had IIS 6.1, except later had SP2. @Mohammadreza – Altaf Patel Sep 16 '14 at 6:34

转载地址:http://vimil.baihongyu.com/

你可能感兴趣的文章
Linux操作命令(六)
查看>>
1、压滤机工作原理
查看>>
设计模式学习总结-桥接模式(Bridge Pattern)
查看>>
halcon算子翻译——copy_image
查看>>
使用Haar分类器进行面部检测
查看>>
参数化(四):处理非均匀数据分布
查看>>
Makefile-2
查看>>
获取页面中出现次数最多的三个标签以及出现次数
查看>>
访问WEB-INF目录中的文件
查看>>
web接口开发与测试
查看>>
php -- php控制linux关机、重启、注销
查看>>
867. Transpose Matrix
查看>>
十.python面向对象(itme)
查看>>
Python下selenium的简单用法
查看>>
multiset的应用
查看>>
我的mysql的学习记录
查看>>
Codeforces Round #416 (Div. 2)(A,思维题,暴力,B,思维题,暴力)
查看>>
NYOJ 题目77 开灯问题(简单模拟)
查看>>
模式识别
查看>>
设置文本编辑器的按回车时触发的事件
查看>>