在网格视图中搜索错误 [英] search in grid view error

查看:80
本文介绍了在网格视图中搜索错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在asp.net的网格视图中使用了数据透镜。除此之外,我还使用搜索框从网格中搜索记录(grdOffice)..当用户查看网格视图时,数据仓工作正常。但是当用户在网格视图中搜索内容时,错误会上升...



数据透镜标记为:



< asp:Label ID =lblProfilerunat =serverText ='<%#DataBinder.Eval(Container,DataItem.genderName)%>'>





c#用户输入文字并点击搜索时绑定数据的代码是..



I have used a databinder in grid view in asp.net.. In addition to it, i have used search box that search for a record from grid(grdOffice).. the databinder works fine when user views the grid view.. but as user search the content in the grid view, an error rises ...

the databinder tag is:

<asp:Label ID="lblProfile" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.genderName") %>'>


c# code for data bound when user enters a text and click on search is..

grdOffice.DataSourceID = string.Empty;
       grdOffice.DataSource = searchOfficeName;
       grdOffice.DataBind();





我得到的错误是:DataBinding:'。DAL.Profile'不会包含一个名为'gender'的属性。



我在表格中有性别ID属性,我属于带性别名称(包含男性和女性)的性别基于性别ID的Profile表的网格视图中的表。



当我绑定grdOffice时,我无法绑定DataBinder.Eval



任何帮助?



the error i get is: "DataBinding: '.DAL.Profile' does not contain a property with the name 'gender'."

I have gender id attribute in table Profile and i pertain to bring genderName (that contains male and female) of gender table in grid view of Profile table based upon gender id.

When I am binding grdOffice,, i cannot bind in DataBinder.Eval

Any help??

推荐答案

错误清楚地表明您没有绑定性别名称属性。检查您的DAL是否也提取了GenderName属性
The error clearly shows that you have no gender name property bound . Check whether your DAL fetches you the GenderName property too


请检查您的DataSource genderNams是否可用。如果没有,那么你不能在gridview中使用它进行数据绑定。进一步如果你想代表性别ID显示genderName,那么我有一个你可以轻松使用的解决方案:

< asp:label Id =lblProfilerunat =serverText ='<%#(Convert.ToString(Eval(genderId))== 1?男:女)%>'>



表示genderId是1然后lable lblProfile显示男性其他女性
please check that in your DataSource genderNams available or not. If not then you can't use this for databinding in gridview. further if you want to display genderName on behalf of gender id then i have a solution for you which you can use easily as :
<asp:label Id="lblProfile" runat="server" Text='<%#(Convert.ToString(Eval("genderId"))==1?Male:Female) %>'>

means if genderId is 1 then lable lblProfile shows Male else Female


这篇关于在网格视图中搜索错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆