rt

解决方案 »

  1.   

    ASP的方法依然可以使用用Response.Write()一行行的输出.....
    DataGrid生成的HTML代码就是Table啊.
      

  2.   

    参考下列代码。
    <asp:Table id="Table1" runat="server" BorderWidth="1px" Width="158px" CellPadding="0" CellSpacing="0"></asp:Table>
    /// <summary>
    /// 输出菜单
    /// </summary>
    private void showMenue()
    {
    DataSet ds = connE.GetDs("father","select * from menues where parentId=1 and state=1 order by id");
    DataView dv = ds.Tables["father"].DefaultView;
    int i=0;
    foreach( DataRowView dvR in dv)
    {
    //一级菜单
    TableRow tr = new TableRow();
    TableCell tc = new TableCell();
    tc.Text=dvR["name"].ToString();
    tc.CssClass="title1";
    tc.Attributes["onclick"]="showsubmenu("+i+")";
    tc.Width=158;
    tc.Height=25;
    tr.Cells.Add(tc);
    Table1.Rows.Add(tr);//二级菜单
    TableRow tr2 = new TableRow();
    TableCell tc2 = new TableCell();
    tc2.ID="submenu"+i;
    tc2.Attributes["style"]="disply:none";Table tbChild = new Table();
    tbChild.CssClass="title2";
    tbChild.Attributes["width"]="100%";DataSet dsChild;
    string strSql="select * from menues where parentId="+dvR["id"]+" and state=1";
    dsChild = connE.GetDs("child",strSql);
    DataView dvChild = dsChild.Tables["child"].DefaultView;
    foreach ( DataRowView dvRChild in dvChild)
    {
    TableRow trChild = new TableRow();
    TableCell tcChild = new TableCell();tcChild.Attributes["align"]="Center";
    HyperLink hl = new HyperLink();
    hl.Text=dvRChild["name"].ToString();
    hl.NavigateUrl=dvRChild["url"].ToString();
    hl.Target="main";
    tcChild.Controls.Add(hl);trChild.Cells.Add(tcChild);
    tbChild.Rows.Add(trChild);
    }
    tc2.Controls.Add(tbChild);
    tr2.Cells.Add(tc2);
    Table1.Rows.Add(tr2);
    //dsChild.Tables.Clear();
    i++;}
    }
      

  3.   

    55555555555555少打了几个字
    我是要table显示数据库分页的例子。
      

  4.   

    示例:
    .aspx文件:
    <table class="text" cellSpacing="1" cellPadding="2" width="100%" align="center" border="0">
    <tr>
    <td class="UpBorder" width="28%"><div align="center">新闻标题</div>
    </td>
    <td class="UpBorder" width="10%"><div align="center">作者</div>
    </td>
    <td class="UpBorder" width="9%"><div align="center">阅览次数</div>
    </td>
    <td class="UpBorder" width="7%"><div align="center">评论数</div>
    </td>
    <td class="UpBorder" width="8%"><div align="center">是否显示</div>
    </td>
    <td class="UpBorder" width="18%"><div align="center">发布时间</div>
    </td>
    <td class="UpBorder" style="WIDTH: 152px" width="152"><div align="center">发布单位</div>
    </td>
    <td class="UpBorder" width="10%"><div align="center">删除</div>
    </td>
    </tr>
    <%  
                                                     CarNewsList();
             %>
    </table>
    .aspx.cs文件:
    protected void CarNewsList()
    {
    list=theCarNewsMgr.GetCarNewsList("",-1);
    PageStart = (CurPage-1)*PageSize;
    if (list != null)
    {
    if (list.Count % PageSize == 0)
    NumPages =list.Count / PageSize;
    else
    NumPages =list.Count / PageSize + 1;
    }
    for(int i=PageStart;i<list.Count && i<PageStart+PageSize;i++)
    {
    theCarNews=(CarNews)list[i];

    if(theCarNews.Display==1)
    {
    Display="Yes";
    }
    else
    {
    Display="No";
    } thecarsaler=thecarsalermgr.GetPublishName(theCarNews.PublishID);
    PublishName=thecarsaler.Name; Response.Write(" <tr bgcolor=\'#ffffff\' onMouseOver=\"this.style.backgroundColor=\'#f7f7f7\';\" onMouseOut=\"this.style.backgroundColor='#ffffff';\"> ");
    Response.Write("<td>&nbsp;<A class=\"forumTitle\" href=\"carnewsaddupdata.aspx?CarNewsID="+theCarNews.ID+"\">"+theCarNews.Title+"</A></td>");
    Response.Write("<td align=\"center\"><font color=\"#999999\">"+theCarNews.Author+"</font></td>");
    Response.Write("<td align=\"center\"><font color=\"#999999\">"+theCarNews.Clicked.ToString()+"</font></td>");
    Response.Write("<td align=\"center\"><font color=\"#ff0000\">"+theCarCommentMgr.CountComment(theCarNews.UnitedID).ToString()+"</font></td>");
    Response.Write("<td align=\"center\"><font color=\"#ff0000\">"+Display+"</font></td>");
    Response.Write("<td align=\"center\"><font color=\"#999999\">"+theCarNews.CreateTime.ToString()+"</font></td>");
    Response.Write("<td align=\"center\"><font color=\"#999999\">"+PublishName+"</font></td>");
    Response.Write("<td><input id=\"del\" type=\"checkbox\" value=\""+theCarNews.ID+"\" name=\"'"+theCarNews.ID+"'\"> <font color=\"#999999\">删除</font></td></tr>"); 
    }
    if(list.Count==0)
    {
    Response.Write("<font color=\"red\">没有找到记录!</font>");
    }
    }
      

  5.   

    http://tech.sina.com.cn/s/2005-01-21/1541511568.shtml
      

  6.   

    有用table控件的例子吗?
    谢谢大家了,今天比较忙,暂时没时间看大家的解释,晚上回来结帖
    再次感谢
      

  7.   

    自己up一个```,``table控件的分页。```大家帮忙。```