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

推荐订阅源

美团技术团队
博客园_首页
量子位
F
Fortinet All Blogs
L
LangChain Blog
The Cloudflare Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
大猫的无限游戏
大猫的无限游戏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
V
Visual Studio Blog
Blog — PlanetScale
Blog — PlanetScale
博客园 - 叶小钗
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - Franky
G
Google Developers Blog
阮一峰的网络日志
阮一峰的网络日志
T
Tailwind CSS Blog
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
有赞技术团队
有赞技术团队
U
Unit 42
IT之家
IT之家

博客园 - 阮

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