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: