惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

雷峰网
雷峰网
宝玉的分享
宝玉的分享
量子位
博客园 - Franky
The Cloudflare Blog
博客园 - 【当耐特】
Jina AI
Jina AI
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
Microsoft Security Blog
Microsoft Security Blog
博客园 - 叶小钗
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
罗磊的独立博客
V
V2EX
MongoDB | Blog
MongoDB | Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
H
Help Net Security
博客园 - 聂微东
F
Fortinet All Blogs
GbyAI
GbyAI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Stack Overflow Blog
Stack Overflow Blog
博客园_首页
人人都是产品经理
人人都是产品经理

博客园 - 阮

Database access assembly build program. - 阮 Remoting: Server encountered an internal error. - 阮 昨天忽然发现被加到training团队中了,遂来发一篇。 利用Brush修改图片,并写入Response一例(网上BBS中贴可变文字图片的例子)。 Avalon 与 3D。 关于QQ的临时消息 Google Search for dot net nuke. 初识 Avalon 通过程序控制Windows传真发送。 VRML Merry Chirstmas. 继续昨天的问题。 What's wrong? 构建安全的 ASP.NET 应用程序。(转) 检测Win Form Datagrid点击cell值的代码,from msdn。 Google search for DNN 终于写完了。 试了试Dot Net Nuke还真爽。 取得天气的WEB地址,weather.com 终于,从System.Windows.Forms.Control继承了一下。
DataGrid不能绑定Field?
· 2004-11-19 · via 博客园 - 阮

也许又是后之后觉,事情是这个样子地。

昨天看了看DNN,弄了个google search,今天,想把它完成,一定要用google的WSDL了,用wsdl.exe生成了一个C#代码,其中result里有一个ResultElement的数组,就要用datagrid绑它,呵呵,可以免去写分页的麻烦何乐而不为呢?

于是有了以下代码

                GoogleSearchService service = new GoogleSearchService();

                GoogleSearchResult result 
=  service.doGoogleSearch (ConfigurationSettings.AppSettings["GoogleKey"],
                    
this.queryTextBox.Text,
                    
0,
                    
10,
                    
false,
                    
"",
                    
false,
                    
"",
                    
"UTF-8",
                    
"UTF-8");

                
this.resultList.DataSource = result.resultElements;
                
this.resultList.DataBind();

绑定写成这样<%# DataBinder.Eval(Container.DataItem,"summary") %>

summary就是ResultElement的一个Field,怎么弄也弄不过去,无奈新建了一个工程试试该怎么绑

            this.resultList.DataSource = new TheElement[]{
                                                             
new TheElement(),
                                                             
new TheElement(),
                                                             
new TheElement(),
                                                             
new TheElement(),
                                                             
new TheElement(),
                                                             
new TheElement()
                                                         }
;
            
this.resultList.DataBind();

当TheElement类的定义是这样的时候,异常。

    public class TheElement
    
{
        
public string Hello = "hello";
    }

当TheElement类的定义改成这样的时候,OK。

    public class TheElement
    
{
        
public string Hello
        
{
            
get
            
{
                
return "Hello";
            }

        }

    }

搞不懂,为什么不让绑Field