首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

Repeater的用法解决方法

2013-06-19 
Repeater的用法script typetext/javascript$(document).ready(function () {$.post(post.ashx, {},

Repeater的用法

  <script type="text/javascript">
        $(document).ready(function () {
            $.post("post.ashx", {}, function (data) {
                if (data <8) {
                    $td = $("#demo1").find("table");
                    $td.css("margin-right", "16px");         
                           }
            });
        })
    </script>

      <div id="demo1" runat="server" style="  padding:0px"> 

           <asp:Repeater runat="server" ID="gv">
        <HeaderTemplate>
             <table   cellspacing="0" rules="all" border="1"  width="80%" >       
        </HeaderTemplate>
        <ItemTemplate>
        
          <tr align="center" >
                        <td width="10%" style=" color:#CCCCCC" >
                               <%#Container.ItemIndex+1%>
                             
                        </td>
                        <td align="center" width="20%" style=" color:#CCCCCC">
                            <%#Eval("Price")%>
                        </td>
                        <td width="20%" style=" color:#CCCCCC">
                            <%#Eval("SubmitNum")%>
                        </td>
                        <td width="20%" style=" color:#CCCCCC">


                            <%#Eval("Bail")%>
                        </td>
                        <td  width="30%" style=" color:#CCCCCC">
                        <%#Eval("CreateTime", "{0:yyyy-MM-dd hh:mm:ss}")%>
                        </td>

                    </tr>
      
        </ItemTemplate>
        <FooterTemplate>
          </table>
        </FooterTemplate>
        </asp:Repeater>
      </div> 

 上面JS中的 data <8 是指如果数据少于8条就给table添加这个样式,因需要现在一定要在后台gv_ItemDataBound 中实现,,不知道怎么在后台怎么添加样式,求大神帮忙,最好能贴出代码,急,,! 

[解决办法]
Repeater的用法解决方法

后台加样式多麻烦,而且发布之后也不好方便修改。可以加css嘛,alternate就是css的一个class样式,我们都这么弄滴
[解决办法]
前台添加 
<tr align="center" id="ttr" runat="server">
然后在ItemDataBound事件中,
通过 HtmlTableRow  tr=e.item.findcontrol('ttr') as HtmlTableRow 好像是这个,记不太清了,
if(tr!=null)
{
 tr.Style.Add("margin-right", "16px");
}
[解决办法]
if (data <8)  这个改成  if (data.length <8) 试试?
[解决办法]
like this?
http://www.cnblogs.com/insus/archive/2013/05/19/3086475.html

热点排行