开发者

how to Specify Repeat times to repeater control

开发者 https://www.devze.com 2023-04-04 03:18 出处:网络
I want to know about some detail of Repeater control. How can i specify the repeat counts to the repeater control.

I want to know about some detail of Repeater control. How can i specify the repeat counts to the repeater control.

for example i have one 开发者_运维知识库textbox in which user enter a digit and repeater control will show specified digit times record of repeater. How can this is possible? Can any one help.?


A Repeater loops the number of times that there are item in its data source. If you want it to repeat n times, you need a data source that has n items.

For example an array:

MyRepeater.DataSource = new int[n];

If you don't use the data source at all in the repeater other than to make it run a specific number of times, then you should perhaps use a simple loop instead of a repeater.


That's not how the repeater works. It's a data-bound control, so you assign any IEnumerable (for example a List of values) and the Repeater will repeat the output for every item in the Collection.

For more information read the MSDN article for this control.

For what you want to do, you can simply add the html code dynamically in a for loop.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号