Single Repeater control record and repeater control

Source: Internet
Author: User

Single Repeater control record and repeater control

A friend asked, put a RadioButton in the first column of the Repeater control to achieve single choice of records.

The following is an example of Insus. NET implementation and description.

Prepare data for the Repeater control:

 

On the ASPX webpage, write the Repeater control:

 

In the ASPX. cs code page, bind the data to the Repeater control:

 
Now let's test run it to see the effect:

The data is displayed, but the single-choice function is faulty, so the single-choice function cannot be implemented. Why? Open the runtime html to see:


No, because the RadioButton of each row generates its own name. Therefore, we can only make our own decisions.
Now we need to find a way to change the attribute values of this name to the same one.

Therefore, Insus. NET thought of rewriting the html of ASPX. Use the regular expression to replace the attribute value with the same one.
For regular expressions, Insus. NET is a weak item. I consulted KONG Wei's friend. The regular expressions he gave are as follows:

(? I )(? <= <Input (?! ((?! (Value | name).) +>) [^ <>] +) name = [^>] + value = "" RadioButton1 ""


In ASPX. cs, the write rewrite method is as follows:



Run and view the html source code again:




 

Now, we can see that the value of the name attribute is the same. As you can imagine, the running effect is normal:


 

Related Article

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.