Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 创建运行时html表时出现性能问题_C#_Asp.net - Fatal编程技术网

C# 创建运行时html表时出现性能问题

C# 创建运行时html表时出现性能问题,c#,asp.net,C#,Asp.net,我有一个asp.net应用程序,需要在页面中创建一个运行时html表。函数从数据库中获取数据,创建html表的运行时,并在页面上呈现。该表包含6-8列和150-200行,每行有一些输入测试框。一切正常,但在aspx页面中呈现html表时存在性能问题。下面是代码 private string GenereateTableData(int rowCount, MyDataList obDataList) { var table = new StringBuilder();

我有一个asp.net应用程序,需要在页面中创建一个运行时html表。函数从数据库中获取数据,创建html表的运行时,并在页面上呈现。该表包含6-8列和150-200行,每行有一些输入测试框。一切正常,但在aspx页面中呈现html表时存在性能问题。下面是代码

  private string GenereateTableData(int rowCount, MyDataList obDataList)
    {
        var table = new StringBuilder();
        string image = string.Empty;
        try
        {

            table.AppendFormat("<tr id='trModelDetail" + rowCount + "' name='RECORDNUM" + rowCount + "' >");

            table.AppendFormat("<td class='aa' align='left' width='80px' style='background-color: #fcfae6;' >");
            table.AppendFormat("<input type='text' name='' id='" + rowCount.ToString() + "' readonly='1' style='width: 75px;background-color: #fcfae6;' class='ActionTBox' maxlength='4' onblur='hideMsgDiv();' value='" + rowCount + "'/>");
            table.AppendFormat("</td>");

            table.AppendFormat("<td class='stdformfont' align='left' width='80px'>");
            table.AppendFormat("<input type='text' name='aa' id='aa' style='width: 75px;' class='' maxlength='10' />");
            table.AppendFormat("<input type='text' name='aa' id='aa' style='width: 75px;display:none; class='ActionTeox' maxlength='10' />");
            table.AppendFormat("</td>");


            table.AppendFormat("</tr>");

            return table.ToString();
        }
        catch (Exception)
        {

            throw;
        }
        finally
        {
            table = null;
        }
    }


    private void ShowData(MyDataList obDataList)
    {
        var table = new StringBuilder();

        try
        {

            table.AppendFormat("<table id='modelDetailsTable' cellpadding='0' cellspacing='0' border='0'>");


            for (int iCount = 0; iCount < obDataList.Count; iCount++)
            {
                // Fill the table with data 
                table.AppendFormat(GenereateTableData(iCount, obDataList[iCount]));

            }

            table.AppendFormat("</table>");

            // Show table in UI
            divData.InnerHtml = table.ToString();

        }
        catch (Exception)
        {

            throw;
        }
        finally
        {
            table = null;

        }
    }
私有字符串generateTableData(int rowCount,MyDataList obDataList)
{
var table=新的StringBuilder();
string image=string.Empty;
尝试
{
表.附录格式(“”);
表.附录格式(“”);
表.附录格式(“”);
表.附录格式(“”);
表.附录格式(“”);
表.附录格式(“”);

table.AppendFormat(“更好的方法是在客户端创建HTML表结构并只传递数据。这将减少从服务器到客户端的大量重复数据传输。您可以使用调用JQuery函数并在客户端处理数据


希望这有帮助。

您的编码部分没有问题。问题是创建的网页对于浏览器来说太重。我建议使用选项卡(需要javascript或其他东西)并减少一次显示的行数。