Repeater 怎么在后台加样式, 在线等, 结贴快 现在需要实现 如果Repeater查出的数据行数大于8条就加上 margin-right:16px 的样式 ,本来用js可以实现,但是在Repeater外有一个定时刷新的UpdatePanel控件,这个控件不可去掉,,当局部刷新后就不会加载js啦, 所以现在我想在后台Repeater绑定的时候加上这个样式, 但是找不到style属性 求解 ,,求大神赐教! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <% if (this.rpList.Items.Count == 0){ %> ..... <%} %> 你可以改成...Count > 8 用.FindControl()找到控件,然后给控件加样式 但是找到了也没有属性是可以加这个样式的找到控件后设置style撒 有点不懂,, 这后面的省略号里怎么写这是前台的,是前台,因为楼主这个需求压根没必要后台去处理,前台耦合标签直接搞定就over了 但是找到了也没有属性是可以加这个样式的找到控件后设置style撒o(︶︿︶)o 不会用, 能给出代码吗? 但是找到了也没有属性是可以加这个样式的找到控件后设置style撒o(︶︿︶)o 不会用, 能给出代码吗? 不用repeater好多年,把你写的发给我,我看看 下班了...sorry不好意思, 刚有事去了 DataTable dt = new DataTable(); dt.Columns.Add("customid"); for (int i = 0; i < 10; i++) { DataRow dr = dt.NewRow(); dr["customid"] = i.ToString(); dt.Rows.Add(dr); } this.rptData.DataSource = dt; this.rptData.DataBind();<style type="text/css"> *{font-family:Arial; font-size:14px;} .li_red{ color:#f00;} </style><form id="form1" runat="server"> <div style=" width:900px; margin:0 auto;"> <asp:Repeater runat="server" ID="rptData"> <HeaderTemplate><ul></HeaderTemplate> <ItemTemplate> <li class=<%#(this.rptData.Items.Count > 8)? "\"li_red\"":"\"\""%>><%# Eval("customid") %></li> </ItemTemplate> <FooterTemplate></ul></FooterTemplate> </asp:Repeater> </div> </form> 或者 public int rptCount = 10; protected void Page_Load(object sender, EventArgs e) { DataTable dt = new DataTable(); dt.Columns.Add("customid"); for (int i = 0; i < 10; i++) { DataRow dr = dt.NewRow(); dr["customid"] = i.ToString(); dt.Rows.Add(dr); } this.rptData.DataSource = dt; this.rptData.DataBind();..... <div style=" width:900px; margin:0 auto;"> <asp:Repeater runat="server" ID="rptData"> <HeaderTemplate><ul></HeaderTemplate> <ItemTemplate> <%--<li class=<%#(this.rptData.Items.Count > 8)? "\"li_red\"":"\"\""%>><%# Eval("customid") %></li>--%> <li><%# Eval("customid") %></li> </ItemTemplate> <FooterTemplate></ul></FooterTemplate> </asp:Repeater> </div> </form> <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { var cc = '<%=rptCount %>'; if (parseInt(cc) > 8) { $("ul li").addClass("li_red"); } }) </script> like this?http://www.cnblogs.com/insus/articles/2060705.html 在你博客里看到UpdatePanel ,, 想请教你一个问题,一个页面怎么同时使用两个UpdatePanel ,而且这两个的定时不一样,,我前面做了设置了两个定时, 但是后面一个的定时没效果。UpdatePanel 和ScriptManager有什么关系? <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" EnableEventValidation="false" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>列表排名</title> <style type="text/css"> *{font-size:12px;list-style:none} ul{padding:0 0;margin-left:10px;margin-top:0px} li{float:left;width:170px;padding:0 0;margin:0 0;line-height:23px} .em {width:16px;height:15px;background:url('Images/split_v3.1.png') no-repeat -207px -127px;float:left;text-align:center;line-height:15px;font-family:Arial;color:#fff;font-size:10px;margin-right:9px;_display:inline;margin-top:2px} .emTop3 {width:16px;height:15px;background:url('Images/split_v3.1.png') no-repeat -207px -100px;float:left;text-align:center;line-height:15px;font-family:Arial;color:#fff;font-size:10px;margin-right:9px;_display:inline;margin-top:2px;} </style></head><body> <form id="form1" runat="server"> <fieldset style="width:180px"> <legend> <fieldset>考试排行榜</fieldset> </legend> <ul> <asp:Repeater runat="server" ID="p1"> <ItemTemplate> <li><span class='<%#Container.ItemIndex<3?"emTop3":"em" %>'><%#Container.ItemIndex+1 %></span> <%#Eval("name")%></li> </ItemTemplate> </asp:Repeater> </ul> </fieldset> </form></body></html> <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" EnableEventValidation="false" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>列表排名</title> <style type="text/css"> *{font-size:12px;list-style:none} ul{padding:0 0;margin-left:10px;margin-top:0px} li{float:left;width:170px;padding:0 0;margin:0 0;line-height:23px} .em {width:16px;height:15px;background:url('Images/split_v3.1.png') no-repeat -207px -127px;float:left;text-align:center;line-height:15px;font-family:Arial;color:#fff;font-size:10px;margin-right:9px;_display:inline;margin-top:2px} .emTop3 {width:16px;height:15px;background:url('Images/split_v3.1.png') no-repeat -207px -100px;float:left;text-align:center;line-height:15px;font-family:Arial;color:#fff;font-size:10px;margin-right:9px;_display:inline;margin-top:2px;} </style></head><body> <form id="form1" runat="server"> <fieldset style="width:180px"> <legend> <fieldset>考试排行榜</fieldset> </legend> <ul> <asp:Repeater runat="server" ID="p1"> <ItemTemplate> <li><span class='<%#Container.ItemIndex<3?"emTop3":"em" %>'><%#Container.ItemIndex+1 %></span> <%#Eval("name")%></li> </ItemTemplate> </asp:Repeater> </ul> </fieldset> </form></body></html> 按照你的编程思路,你就不应该用那么低级的Repeater,而应该是什么最合适用什么。例如DataList、GridView之类的。对你来说,控件Repeater没有什么内涵可以帮你提高开发速度,因此你找不到Style属性。 其实某些人、使用Repeater的人,完全可以非常同意地在自己的代码中用一、两分钟时间解决这个问题。但是你根本不知道在提问题时必须告诉别人什么信息才能求助,足以证明你不是这类人。那么我最直接的建议,就是你应该使用对你更加合适的控件来开发,而不是Repeater。 如果Repeater查出的数据行数大于8条就加上 margin-right:16px 的样式 ,本来用js可以实现,但是在Repeater外有一个定时刷新的UpdatePanel控件,这个控件不可去掉,,当局部刷新后就不会加载js啦, 所以现在我想在后台Repeater绑定的时候加上这个样式, 但是找不到style属性 求解 ,,求大神赐教! Refer:http://www.cnblogs.com/insus/archive/2013/05/19/3086475.html SharePoint提供了哪些服务? js激发事件 注册了跳到用户中心页面,没有注册的话跳到主界面,这个怎么实现?? 上传文件到一个服务器下 的文件夹里? 上班的时候老困怎么办 ? 上班的时候老困怎么办 ? 上班的时候老困怎么办 ? 救命啊,初学者的一个小问题,希望大家能帮我解决此问题 这段C#语言,对应的VB.net语言? 为何我点击 提交 按钮 ,没有跳转至 submt? 高分:如何使四层体系中的数据实体层更灵活一些 .net里有没有播放视屏的组件?? 页面跳转 asp.net有那些开源的商城源码?
但是找到了也没有属性是可以加这个样式的找到控件后设置style撒
有点不懂,, 这后面的省略号里怎么写
这是前台的,
是前台,因为楼主这个需求压根没必要后台去处理,前台耦合标签直接搞定就over了
但是找到了也没有属性是可以加这个样式的找到控件后设置style撒
o(︶︿︶)o 不会用, 能给出代码吗?
但是找到了也没有属性是可以加这个样式的找到控件后设置style撒
o(︶︿︶)o 不会用, 能给出代码吗? 不用repeater好多年,把你写的发给我,我看看
下班了...sorry不好意思, 刚有事去了
dt.Columns.Add("customid");
for (int i = 0; i < 10; i++)
{
DataRow dr = dt.NewRow();
dr["customid"] = i.ToString();
dt.Rows.Add(dr);
}
this.rptData.DataSource = dt;
this.rptData.DataBind();
<style type="text/css">
*{font-family:Arial; font-size:14px;}
.li_red{ color:#f00;}
</style><form id="form1" runat="server">
<div style=" width:900px; margin:0 auto;">
<asp:Repeater runat="server" ID="rptData">
<HeaderTemplate><ul></HeaderTemplate>
<ItemTemplate>
<li class=<%#(this.rptData.Items.Count > 8)? "\"li_red\"":"\"\""%>><%# Eval("customid") %></li>
</ItemTemplate>
<FooterTemplate></ul></FooterTemplate>
</asp:Repeater>
</div>
</form>
public int rptCount = 10;
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("customid");
for (int i = 0; i < 10; i++)
{
DataRow dr = dt.NewRow();
dr["customid"] = i.ToString();
dt.Rows.Add(dr);
}
this.rptData.DataSource = dt;
this.rptData.DataBind();
..... <div style=" width:900px; margin:0 auto;">
<asp:Repeater runat="server" ID="rptData">
<HeaderTemplate><ul></HeaderTemplate>
<ItemTemplate>
<%--<li class=<%#(this.rptData.Items.Count > 8)? "\"li_red\"":"\"\""%>><%# Eval("customid") %></li>--%>
<li><%# Eval("customid") %></li>
</ItemTemplate>
<FooterTemplate></ul></FooterTemplate>
</asp:Repeater>
</div>
</form>
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
var cc = '<%=rptCount %>';
if (parseInt(cc) > 8) {
$("ul li").addClass("li_red");
}
})
</script>
http://www.cnblogs.com/insus/articles/2060705.html
<head runat="server">
<title>列表排名</title>
<style type="text/css">
*{font-size:12px;list-style:none}
ul{padding:0 0;margin-left:10px;margin-top:0px}
li{float:left;width:170px;padding:0 0;margin:0 0;line-height:23px}
.em {width:16px;height:15px;background:url('Images/split_v3.1.png') no-repeat -207px -127px;float:left;text-align:center;line-height:15px;font-family:Arial;color:#fff;font-size:10px;margin-right:9px;_display:inline;margin-top:2px}
.emTop3 {width:16px;height:15px;background:url('Images/split_v3.1.png') no-repeat -207px -100px;float:left;text-align:center;line-height:15px;font-family:Arial;color:#fff;font-size:10px;margin-right:9px;_display:inline;margin-top:2px;}
</style>
</head>
<body>
<form id="form1" runat="server">
<fieldset style="width:180px">
<legend>
<fieldset>考试排行榜</fieldset>
</legend>
<ul>
<asp:Repeater runat="server" ID="p1">
<ItemTemplate>
<li><span class='<%#Container.ItemIndex<3?"emTop3":"em" %>'><%#Container.ItemIndex+1 %></span> <%#Eval("name")%></li>
</ItemTemplate>
</asp:Repeater>
</ul>
</fieldset>
</form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" EnableEventValidation="false" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>列表排名</title>
<style type="text/css">
*{font-size:12px;list-style:none}
ul{padding:0 0;margin-left:10px;margin-top:0px}
li{float:left;width:170px;padding:0 0;margin:0 0;line-height:23px}
.em {width:16px;height:15px;background:url('Images/split_v3.1.png') no-repeat -207px -127px;float:left;text-align:center;line-height:15px;font-family:Arial;color:#fff;font-size:10px;margin-right:9px;_display:inline;margin-top:2px}
.emTop3 {width:16px;height:15px;background:url('Images/split_v3.1.png') no-repeat -207px -100px;float:left;text-align:center;line-height:15px;font-family:Arial;color:#fff;font-size:10px;margin-right:9px;_display:inline;margin-top:2px;}
</style>
</head>
<body>
<form id="form1" runat="server">
<fieldset style="width:180px">
<legend>
<fieldset>考试排行榜</fieldset>
</legend>
<ul>
<asp:Repeater runat="server" ID="p1">
<ItemTemplate>
<li><span class='<%#Container.ItemIndex<3?"emTop3":"em" %>'><%#Container.ItemIndex+1 %></span> <%#Eval("name")%></li>
</ItemTemplate>
</asp:Repeater>
</ul>
</fieldset>
</form>
</body>
</html>
http://www.cnblogs.com/insus/archive/2013/05/19/3086475.html