repeater 多行多列+该背景色

 

cs:

    
using  System;
using  System.Data;
using  System.Configuration;
using  System.Collections;
using  System.Web;
using  System.Web.Security;
using  System.Web.UI;
using  System.Web.UI.WebControls;
using  System.Web.UI.WebControls.WebParts;
using  System.Web.UI.HtmlControls;
using  System.Data.SqlClient;


public  partial  class  clinic_index : System.Web.UI.Page
{
      
protected int i = 0;
      
public string strsql, beijingse;

      
protected void Page_Load(object sender, EventArgs e)
      
{
          strsql 
= "select top 64 business_id,left(business_name,10),left(business_company,10) from business where business_type like '%处方%' order by business_cishu desc";
          SqlConnection con 
= new SqlConnection(ConfigurationSettings.AppSettings["Str_sql"]);
          con.Open();
          DataSet ds 
= new DataSet();

          
// 火暴招商1 rpt_hbzs
          SqlDataAdapter sda_hbzs = new SqlDataAdapter(strsql, con);
          sda_hbzs.Fill(ds,
0,32,"hbzs");
          rpt_hbzs.DataSource 
= ds.Tables["hbzs"];
          rpt_hbzs.DataBind();

          sda_hbzs.Fill(ds,
32,32,"hbzs2");

          rpt_hbzs2.DataSource 
= ds.Tables["hbzs2"];
          rpt_hbzs2.DataBind();


          sda_hbzs.Dispose();

       



          con.Close();
          con.Dispose();

      }

      
protected void Repeater1_ItemDataBound(object sender,System.Web.UI.WebControls.RepeaterItemEventArgs e)
      
{
          
if (i % 4 == 0 && i > 0)
          
{
              e.Item.Controls.Add(
new System.Web.UI.LiteralControl("</tr><tr>"));
            
           
          }

          
if (i == 0 || i==1 || i==2 || i ==3    || i ==8 || i ==9 || i ==10 || i ==11 || i ==16 || i ==17 || i ==18 || i ==19 || i ==24 || i ==25 || i ==26 || i ==27 )
          
{
              beijingse 
= "#f7fbf7";
          }

          
else
          
{
              beijingse 
= "#e7f3ff";
          }

          i
++;

      }

}

aspx:

     
< asp:Repeater ID = " rpt_hbzs "  runat = " server "  OnItemDataBound = " Repeater1_ItemDataBound " >
                
< HeaderTemplate >< table width = " 100% "  border = " 0 "  align = " center "  cellpadding = " 0 "  cellspacing = " 1 "  bgcolor = " #92C9C6 " >< tr ></ HeaderTemplate >
                  
< ItemTemplate >
                
                  
< td height = " 22 "  bgcolor = ' <%#beijingse %> '  width = " 25% " >
                   [
<% # DataBinder.Eval(Container.DataItem,  " business_company " ) %> ]     < a href = ' <%#DataBinder.Eval(Container.DataItem,"business_id") %> '   >  
                            
<% #DataBinder.Eval(Container.DataItem, " business_name " %>  
                          
                     
</ a >   
                  
</ td >  
                  
</ ItemTemplate >
             
                  
< FooterTemplate >   </ tr ></ table ></ FooterTemplate >
                
</ asp:Repeater >
              

转载于:https://www.cnblogs.com/Fernando/archive/2007/12/06/984834.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值