ASP.net直放站

编程入门 行业动态 更新时间:2024-10-22 18:33:22
本文介绍了ASP直放站 - N设置重复次数最多?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用的是Repeater控件现在上显示来自多个不同的网站SQL Server数据。我想知道,如果有任何方式的做一个中继器只有重复或通过其运行周期最多N次。的

I am using a Repeater control to display data from a SQL server on multiple different sites right now. I am wondering if there is any way to make a repeater only "repeat" or run through its cycles a maximum of N times.

我拆了一个div元素融入其中4只是有足够的空间容纳该转发器的4个周期相等的部分。如果它运行的4倍以上,这一切都推下来div和图像开始/文我会preFER避免新行。它使网页看起来丑陋并没有真正大有作为的客户端。

I split a Div element up into 4 equal sections which have just enough room for 4 cycles of this repeater. If it runs more than 4 times, it pushes everything down in the div and begins a new row of images/text I would prefer to avoid. It makes the web page look uglier and does not really accomplish much for the client.

另外,有没有办法为随机选择它通过中继器循环上得到显示?例如,有一次页面加载,中继器重复拉2-5,那么刷新页面,中继拉迭代1-4。这将是非常酷的,如果我能有这样的出现是随机的图像/文本。

Also is there any way to randomly select which iterations through the repeater get displayed? For example, one time the page loads, the repeater pulls iterations 2-5, then you refresh the page and the repeater pulls iterations 1-4. That would be very cool if I could make the images/text that show up to be random.

对于那些很好奇,一个转发器是一个ASP对象基本上反复显示或以其他方式从表中,SQL数据库等数据打交道它只是由行到任何的数据去行。

For those that are curious, a repeater is an ASP object which basically iteratively displays or otherwise works with data from a table, SQL database, etc. It just goes row by row through whatever the data is.

推荐答案

而不是试图做任何时髦与中继器,你可以将它绑定到你的中继之前,这样做是为了您的数据源本身。

Rather than try to do anything funky with the repeater, you can do this to your data source itself before binding it to your repeater.

例如:

var rand = new Random(); var myCollection = GetSomethingFromSomewhere(); myRepeater.DataSource = myCollection .OrderBy(x => rand.Next()) .Take(4); myRepeater.DataBind();

更多推荐

ASP.net直放站

本文发布于:2023-10-24 17:05:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1524513.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:直放站   ASP   net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!