绑定评估值 [英] Binding an Eval Value

查看:70
本文介绍了绑定评估值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里需要一些有关如何在gridview中正确绑定文本评估值的帮助.

请参见下面的代码.

Need some help here as to how to bind a text eval value properly in a gridview.

Please see code below.

 <asp:TemplateField HeaderText="Rate" Visible="True">
                    <ItemTemplate>
                       
                        <asp:Label ID="lblRate" runat="server"

Text='<%#GetLabelText(Eval("platinumRate"), Eval("goldRate"), Eval("silverRate"))%>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>



后面的代码是:



code behind is:

public string GetLabelText(Object platinumRate, Object goldRate, Object silverRate)
       {
           if (DropDownList1.SelectedValue == "Platinum")
           {
               return DataBinder.Eval(platinumRate,"platinumRate").ToString();
           }
           else if (DropDownList1.SelectedValue == "Gold")
           {
               return DataBinder.Eval(goldRate, "goldRate").ToString();
           }
           else
           {
               return DataBinder.Eval(silverRate, "silverRate").ToString();
           }

       }



此刻我得到了错误:

数据绑定:"System.Decimal"不包含名称为"platinumRate"的属性.

如果可以的话请帮忙.

关于



At the moment I get the error:

DataBinding: ''System.Decimal'' does not contain a property with the name ''platinumRate''.

Please help if you can.

Regards

推荐答案

我唯一想到的是:
1.您选择的查询中的字段名称错误
2. gridview中的数据字段与数据源中的字段不匹配
3.区分大小写吗?
4.类型不匹配?

更有可能是其字段不匹配,如拼写错误.
the only thing that i can think of are:
1. wrong field name in your select query
2. datafield in gridview and fields in your datasource mismatch
3. case sensitive?
4. type mismatch?

more likely its field mismatch like typo error.


这篇关于绑定评估值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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