从GridView控件使用eval(;;&QUOT&QUOT)从.aspx文件访问公共静态类文件 [英] Accessing public static class files from .ASPX file using Eval("") from gridView

查看:86
本文介绍了从GridView控件使用eval(;;&QUOT&QUOT)从.aspx文件访问公共静态类文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我是新来这个系统,请善待我。我现在遇到的问题是无法通过评估和演示调用从ASPX类文件。类文件位于〜/类文件夹中。请为我提供的方法和方式来逃避这种错误甚至解决谢谢! ^^

编程语言:C#

问题在发现:.ASPX GridView的

问题在还发现:EstateDBManager类文件

错误消息:数据绑定:DWAD_Project.classes.Volunteer'不包含名为'EstateDBManager的属性。

codeS下面部分的GridView

 < ASP:的TemplateField的HeaderText =村名SORTEX pression =EstateId>
      <&EditItemTemplate的GT;
        < ASP:文本框ID =TextBox1的=服务器文本='<%#的eval(EstateDBManager.findEstate({0})名称。)%>'>< / ASP:文本框>
      < / EditItemTemplate中>
      <&ItemTemplate中GT;
        < ASP:标签ID =Label1的=服务器文本='<%#的eval(EstateDBManager.findEstate({0})名称。)%>'>< / ASP:标签>
      < / ItemTemplate中>
    < / ASP:的TemplateField>

codeS局部EstateDBManager类文件如下:

 命名空间DWAD_Project.classes
    {
      公共静态类EstateDBManager
      {
        公共静态村findEstate(INT ID)
        {
           //过程...
        }
      }
    }

谢谢回复和帮助! ^^







这个问题的答案

GridView控件

 < ASP:的TemplateField的HeaderText =村名SORTEX pression =EstateId>
      <&EditItemTemplate的GT;
        < ASP:文本框ID =TextBox1的=服务器文本='<%#DWAD_Project.classes.EstateDBManager.findEstate(EVAL(EstateId))名称%方式>'>< / ASP:文本框>
      < / EditItemTemplate中>
      <&ItemTemplate中GT;
        < ASP:标签ID =Label1的=服务器文本='<%#DWAD_Project.classes.EstateDBManager.findEstate(EVAL(EstateId))名称%方式>'>< / ASP:标签>
      < / ItemTemplate中>
    < / ASP:的TemplateField>

类文件

 命名空间DWAD_Project.classes
    {
      公共静态类EstateDBManager
      {
        公共静态村findEstate(INT ID)
        {
           //过程...
        }
      }
    }


解决方案

评估是数据源的属性。如果你只需要code不使用eval

 '<%#EstateDBManager.findEstate(EVAL(EstateId))名称%方式>

您只需要在评估和演示结果转换为正确的类型,因为它是对象(例如(INT)的eval(EstateId))

Hi I am new to this system, please be gentle with me. The problem I am now having is the inability to call the class file from ASPX through Eval. The class file is located in "~/classes" folder. Please provide me with methods and ways to evade this error or even solve it thank you!! ^^

Programming language : C#
Problem found in : .ASPX gridView
Problem also found in : EstateDBManager class file
Error Message : DataBinding: 'DWAD_Project.classes.Volunteer' does not contain a property with the name 'EstateDBManager'.
Codes for partial gridView below :

    <asp:TemplateField HeaderText="Estate Name" SortExpression="EstateId">
      <EditItemTemplate>
        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("EstateDBManager.findEstate({0}).Name") %>'></asp:TextBox>
      </EditItemTemplate>
      <ItemTemplate>
        <asp:Label ID="Label1" runat="server" Text='<%# Eval("EstateDBManager.findEstate({0}).Name") %>'></asp:Label>
      </ItemTemplate>
    </asp:TemplateField>

Codes for partial EstateDBManager Class file below:

    namespace DWAD_Project.classes
    {
      public static class EstateDBManager
      {
        public static Estate findEstate(int ID)
        {
           // processes ...
        }
      }
    }

Thanks for replies and helps!! ^^






Answer to the problem:
GridView :

      <asp:TemplateField HeaderText="Estate Name" SortExpression="EstateId">
      <EditItemTemplate>
        <asp:TextBox ID="TextBox1" runat="server" Text='<%# DWAD_Project.classes.EstateDBManager.findEstate(Eval("EstateId")).Name %>'></asp:TextBox>
      </EditItemTemplate>
      <ItemTemplate>
        <asp:Label ID="Label1" runat="server" Text='<%# DWAD_Project.classes.EstateDBManager.findEstate(Eval("EstateId")).Name %>'></asp:Label>
      </ItemTemplate>
    </asp:TemplateField>

Class file :

    namespace DWAD_Project.classes
    {
      public static class EstateDBManager
      {
        public static Estate findEstate(int ID)
        {
           // processes ...
        }
      }
    }

解决方案

Eval is for properties of the data source. If you need just code don't use Eval

'<%# EstateDBManager.findEstate(Eval("EstateId")).Name %>'

You just have to convert the Eval result to the right type since it is object (e.g. (int)Eval("EstateId"))

这篇关于从GridView控件使用eval(;;&QUOT&QUOT)从.aspx文件访问公共静态类文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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