这样读出只有一列显示.
<uc1:bizsupply id="BizSupply1" runat="server" ShowType="2" InfoCount="10" DemandTag="[求购]"></uc1:bizsupply>现在我想让他分两列显示,有没有办法.

解决方案 »

  1.   

    这是BizSupply.ascx代码...边结帖边等~!
    <%@ Import Namespace="Project.Business.DBOperator.BusinessInfo"%>
    <%@ Control Language="c#" AutoEventWireup="false" Codebehind="BizSupply.ascx.cs" Inherits="Project.UserControl.BizSupply" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
    <%@ Import namespace="System.Data" %>
    <%@ OutputCache Duration="60" VaryByParam="none" %>
    <%@ import namespace="Project.ToolHelper" %><table cellSpacing=0 cellPadding=0 width=100% align=center border=0 >  <!--外表嵌套--开始//-->
    <tr>
    <td>
    <%
    DataTable dt=GetInfoData();   //获取数据
    int RowCount = dt.Rows.Count;
       
    if(dt==null || RowCount == 0)  //当没有数据时,显示一个相同大小的空表
    {%>
    <table cellSpacing=0 cellPadding=0 width=100% align=center border=0><!--内表嵌套//-->

    <%for (int intLoop = 1;intLoop <= Convert.ToInt32(RowCount);intLoop ++ ){%>
    <tr>
    <td height="20">&nbsp;</td>
    </tr>
    <%}%>

    </table> <!--内表嵌套--结束//-->

    <%}else{ //数据显示时%>   

    <table cellSpacing=0 cellPadding=0 width=100% align=center border=0>  <!--内表嵌套//-->

    <%   
    int showRow = RowCount/ColCount;
    int showOtherColumns = RowCount%ColCount;

    DataRow dr;
    for(int i=0;i<showRow;i++)
    {
    %>
    <tr><!--行开始//-->
     <% for(int j=0;j<ColCount;j++)
    {
    dr = dt.Rows[i*ColCount+j]; 
    sConvertStr=ToolHelper.HtmlEncode(dr[BusinessInfoData.BUSINESSINFO_PRODUCTNAME].ToString());
    sConvertDate=dr[BusinessInfoData.BUSINESSINFO_PUBTIME].ToString();


    if(TitleBeforImage!="")  //判断标题前是否有小图片,当没有的时候显示“·”
    { %>
    <td align="left" height="20"><img src=<%=TitleBeforImage%> align=middle border=0>
    <%}else{%>
    <td align="left">·
    <% }    //判断标题前是否有小图片,当没有的时候。结束 %>

    <A href="/product/ViewProduct.aspx?ID=<%=dr[BusinessInfoData.BUSINESSINFO_ID].ToString()%>" target=_blank><%=FormatTitle(sConvertStr,dr[BusinessInfoData.BUSINESSINFO_DIRECTIONID])%></A></td>
    <td align="right" height="20">

    <%if(dr[BusinessInfoData.BUSINESSINFO_PUBTIME].ToString()!=null)
    {
    Response.Write (FormatDateTime(sConvertDate,DateStyle));
    }

    %></td>
     <% } %>
    </tr><!--行结束//-->
      <%}
    if(showOtherColumns > 0){ // 多列时,是否出现不够填充一行时,显示最后一行 %>

    <tr><!--行开始-->
      <%for(int i=RowCount - showOtherColumns ;i<RowCount;i++)
    {
    dr = dt.Rows[i]; 
    sConvertStr=ToolHelper.HtmlEncode(dr[BusinessInfoData.BUSINESSINFO_PRODUCTNAME].ToString());
    sConvertDate=dr[BusinessInfoData.BUSINESSINFO_PUBTIME].ToString();

    if(TitleBeforImage!="")  //判断标题前是否有小图片,当没有的时候显示“·”
    { %>
    <td align="left" height="20"><img src=<%=TitleBeforImage%> align=middle border=0>
    <%}else{%>
    <td align="left">·
    <% }    //判断标题前是否有小图片,当没有的时候。结束 %>

    <A href="/product/ViewProduct.aspx?ID=<%=dr[BusinessInfoData.BUSINESSINFO_ID].ToString()%>" target=_blank><%=FormatTitle(sConvertStr,dr[BusinessInfoData.BUSINESSINFO_DIRECTIONID])%></A></td>
    <td align="right" height="20">

    <%if(dr[BusinessInfoData.BUSINESSINFO_PUBTIME].ToString()!=null)
    {
    Response.Write (FormatDateTime(sConvertDate,DateStyle));
    }%>
    </td>
     <% }
     
    // 插入空白单元格
    for(int i=showOtherColumns ;i<ColCount;i++)
    { %>
    <td height="20">&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
     <% } %>

    </tr><!--行接受-->
    <%} %>
    </table>  <!--内表嵌套--结束//-->
    <% } %>
      </td></tr>
    </table><!--外表--结束//-->