动态HTML表格与静态html表格重叠 [英] Dynamic Html Table overlap on Static html table

查看:120
本文介绍了动态HTML表格与静态html表格重叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的default.aspx代码(创建一个包含1行和2个单元格的表)

This is my default.aspx code(create a table with 1 row and 2 cells)

<div id="id1">
    <table>
    <tr>
    <td>
        <asp:DropDownList ID="DropDownList1" runat="server" 

            DataSourceID="SqlDataSource1" DataTextField="firstname" 

            DataValueField="firstname" AppendDataBoundItems="true" >
            <asp:ListItem  Text="All" Value="-1" />
        
        </td>
        <td>
        <asp:Button ID="Button1" runat="server" BackColor="#E1E1E1" 

            Text="Display Report" onclick="Button1_Click" OnClientClick="html()" />
            </td>
           
            </tr>
</table>
</div>



这是我的default.aspx.cs代码.在这里,我使用stringbuilder动态创建了表.



This is my default.aspx.cs code..Here i ahve created dynamically table using stringbuilder..

StringBuilder strhtmlcontent = new StringBuilder();
//table starts
strhtmlcontent.Append("<table align="Center" style="background-color:#" border-collapse:collapse="" cellspacing="0" rules="all" border="1" width="100%" xmlns:border-collapse="#unknown"><th width="8%" bgcolor="#DFDFFF">FirstName</th><th width="10%" bgcolor="#DFDFFF">Product Name</th><th width="10%" bgcolor="#DFDFFF">Client Name</th><th width="10%" bgcolor="#DFDFFF">Amount</th><th width="10%" bgcolor="#DFDFFF">Activity Date</th>");

strhtmlcontent.Append("</table>");
//table Ends



当我运行项目时,在default.aspx页中创建的表低于动态创建的表.
这样的意思
//table1(使用stringbuilder动态使用)
下面
//table2(aspx页面上的静态页面)

但我想要...像这样

//table2(aspx页面上的静态页面)
下面
//table1(使用stringbuilder动态.)

谢谢



When i run the project.. table created in default.aspx page is below that of dynamically created table..

Means like this
//table1 (dynamic using stringbuilder)
below
//table2 (static on aspx page)

But i want...like this

//table2 (static on aspx page)
below
//table1 (dynamic using stringbuilder.)

thanks

推荐答案

如果能够成功追加,也可以使用StringBuilder.Insert(int, string)插入,并使用零索引进行调用.

—SA
If you were able to successfully append, you could insert as well using StringBuilder.Insert(int, string), call it with zero index.

—SA


在aspx页面中,您还可以使用asp:Literal控件定义希望table2出现的位置.

aspx:
In your aspx page, you could also use an asp:Literal control to define the location where you want table2 to appear.
i.e.
aspx:
<asp:literal id="litTable1" runat="server" xmlns:asp="#unknown" />
<table id="table1" ...="">
   ...
</table>


.cs:


.cs:

...
StringBuilder strhtmlcontent = new StringBuilder();
// build your table
litTable1.Text = strhtmlcontent;


这篇关于动态HTML表格与静态html表格重叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆