Strong ASP. NET data binding feature version)

Source: Internet
Author: User

 

After reading what dragonpig wrote, "teach you 30 seconds to create a strong type of ASP. NET data binding", it was so powerful that we could still bind data like this.

I immediately tested it and made some improvements. It has been applied to the news section in home. Next, I will share my experiences on improvement.

Using the traditional ASP. NET data binding method, there are two aspects that have always been unpleasant:

1) Lack of smart sensing;

2) Forced type conversion.

Let's take a look at the traditional ASP. NET data binding:

Look at the top tostring (), (datetime )...

The idea of strong Type Binding of dragonpig already includes methods to solve these two problems,CodeSolved the first problem (SMART awareness), but ignored the second problem (forced type conversion). The original code is as follows:

  Protected     Virtual     Object Exphelper  <  Tentity, tresult  >  (Func  <  Tentity, tresult  >  Func)
{
VaR ITM = Getdataitem ();
Return Func (tentity) ITM );
}
Protected Object Stu < Tresult > (Func < Student, tresult > Func)
{
Return Exphelper < Student, tresult > (Func );
}

During use, I found that forced type conversion was still required. It was a bit uncomfortable. After studying it, it turned out to be a curse of the object. As long as we changed the two objects in the above Code to tresult, the problem was solved.

In addition, I changed the stu method name to eval, which is more friendly.

Code:

  Protected     Virtual  Tresult exphelper  <  Tentity, tresult  >  (Func  <  Tentity, tresult  >  Func)
{
VaR item = Base . Getdataitem ();
Return Func (tentity) item );
}
Protected Tresult eval < Tresult > (Func < Newsinfo, tresult > Func)
{
Return Exphelper < Newsinfo, tresult > (Func );
}

With "strong ASP. NET data binding", the days are wonderful...

Thank you, dragonpig! Your sharing is awesome!

After reading what dragonpig wrote, "teach you 30 seconds to create a strong type of ASP. NET data binding", it was so powerful that we could still bind data like this.

I immediately tested it and made some improvements. It has been applied to the news section in home. Next, I will share my experiences on improvement.

Using the traditional ASP. NET data binding method, there are two aspects that have always been unpleasant:

1) Lack of smart sensing;

2) Forced type conversion.

Let's take a look at the traditional ASP. NET data binding:

Look at the top tostring (), (datetime )...

The idea of strong Type Binding of dragonpig already includes methods to solve these two problems, but in the code displayed by dragonpig, it solves the first problem (SMART awareness ), however, the second problem is ignored (forced type conversion). The original code is as follows:

  Protected     Virtual     Object  Exphelper  <  Tentity, tresult  >  (Func  <  Tentity, tresult  >  Func)
{
VaR ITM = Getdataitem ();
Return Func (tentity) ITM );
}
Protected Object Stu < Tresult > (Func < Student, tresult > Func)
{
Return Exphelper < Student, tresult > (Func );
}

During use, I found that forced type conversion was still required. It was a bit uncomfortable. After studying it, it turned out to be a curse of the object. As long as we changed the two objects in the above Code to tresult, the problem was solved.

In addition, I changed the stu method name to eval, which is more friendly.

Code:

  Protected     Virtual  Tresult exphelper  <  Tentity, tresult >  (Func  <  Tentity, tresult  >  Func)
{
VaR item = Base . Getdataitem ();
Return Func (tentity) item );
}
Protected Tresult eval < Tresult > (Func < Newsinfo, tresult > Func)
{
Return Exphelper < Newsinfo, tresult > (Func );
}

With "strong ASP. NET data binding", the days are wonderful...

Thank you, dragonpig! Your sharing is awesome!

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.