绑定泛型列表阵列来的GridView [英] Binding Generic List Array to GridView

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

问题描述

您好我有一个列表,返回问题的数组。我的问题是我怎么可以绑定这一个网格视图?当我尝试打电话Question.Ordinal我得到它不会在数据源中存在。我现在用的是下面的code:

Hi I have a List which returns an array of "Question". My question is how can I bind this to a grid view? When I try to call Question.Ordinal I get that it does not exist in the data source. I am using the following code:

GridView1.DataSource = myList.GetQ();
GrdiView1.DataBind();

myList.GetQ()返回一个列表这是问题的数组。

myList.GetQ() returns a List which is an array of "Question".

当我将列数据字段为!我得到的对象问题。我的问题是如何获得这些对象的财产?我想!.Ordinal不工作。我在读这篇文章仅供参考,这里,任何帮助是极大的AP preciated,谢谢。

When I set the column DataField to "!" I get the object Question. My question is how can I get the objects property? I tried "!.Ordinal" does not work. I was reading this post for reference, here, any help is greatly appreciated, thanks.

推荐答案

您必须定义类的属性成员,作为一个属性格式,即

you must be define the property member of class, as a propery ie

public string ProductName
{
    get
    {
        return _productName;
    }
    set { }

}

或VB

公物产品名称()作为字符串 设置..

public property ProductName() as string set ..

获取...

高端物业

重要:不需要定义get方法

important: Is Required defined get method

这篇关于绑定泛型列表阵列来的GridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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