The DataGrid cannot be bound to a field?

Source: Internet
Author: User

This may be the way things look.

Yesterday, I looked at dnn and made a Google search. Today, I want to complete the search. I must use Google's wsdland use wsdl.exe to generate a C #CodeIn the result, there is a resultelement array, and we need to bind it with the DataGrid. Why not bother writing paging?

So with the following code

Googlesearchservice Service =   New Googlesearchservice ();

Googlesearchresult result = Service. dogooglesearch (configurationsettings. deleetask [ " Googlekey " ],
This . Querytextbox. Text,
0 ,
10 ,
False ,
"" ,
False ,
"" ,
" UTF-8 " ,
" UTF-8 " );

This . Resultlist. datasource =   Result. resultelements;
This . Resultlist. databind ();

The binding format is as follows: <% # databinder. eval (container. dataitem, "summary") %>

Summary is a field of resultelement. You can't get it. Instead, you have to create a new project and try how to bind it.

This . Resultlist. datasource =   New Theelement [] {
New Theelement (),
New Theelement (),
New Theelement (),
New Theelement (),
New Theelement (),
New Theelement ()
} ;
This . Resultlist. databind ();

When theelement class is defined like this, an exception occurs.

Public   Class Theelement
{
Public StringHello= "Hello";
}

When theelement class is defined like this, OK.

Public   Class Theelement
{
Public   String Hello
{
Get
{
Return "Hello";
}
}
}

Why not bind a field.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.