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>这是显示一列.我现在想显示两列怎么改?后台程序是封装过的.改不了.我新手,高手指教

解决方案 »

  1.   

    添加j,if(j%2==0)添加</tr>结束符
    或datalist控件绑定数据,设置两行,更简单
      

  2.   


    <asp:DataList ID="BizSupply" runat="server" RepeatColumns="2" Width="95%" Height="268">
         <ItemTemplate>
            <uc1:bizsupply id="BizSupply1" runat="server" ShowType="2" InfoCount="10" DemandTag="[求购]"></uc1:bizsupply>
         </ItemTemplate>
         <ItemStyle HorizontalAlign="Left" />
    </asp:DataList>前台这样写就不显示了~!
    <uc1:bizsupply id="BizSupply1" runat="server" ShowType="2" InfoCount="10" DemandTag="[求购]"></uc1:bizsupply>
    这样是显示的.不过只有一列,我想显示两列
      

  3.   

    用datalist吧,它有属性可以设置分多列显示的
      

  4.   

    上面我的DATALIST但是不显示...不知道为什么