日期:2014-05-17  浏览次数:20670 次

girdview前台字段怎样绑定后台的方法呢?
/// <summary>
        /// 得到一个对象实体
        /// </summary>
        public string  GetModel(int id)
        {
            Model.SubjectType mod = new Model.SubjectType();
            BLL.SubjectType blls = new BLL.SubjectType();
            mod=blls.GetModel(id);
            return mod.subjectTypeName;
        }
这是我写在cs文件下的方法 
我想在gridview中绑定这个方法,然后像是相对应的string 对象

 <asp:Label ID="Label1" runat="server" Text='<%#GetModel.Eval("SubjectTypeId")%>'></asp:Label>
这是我后台的绑定。。总是出错。。应该怎么绑定呢?? 急急急急!!
------最佳解决方案--------------------
很简单的嘛

<asp:Label ID="Label1" runat="server" Text='<%#GetModel(int.Parse(Eval("SubjectTypeId").ToString()))%>'></asp:Label>