Datatable to html Table

前端 未结 8 2013
感动是毒
感动是毒 2020-11-27 14:42

I have question, that maybe someone here wouldn\'t mind to help me with. I have lets say 3 datatables, each one of them has the following columns:

size, quantity, amo

相关标签:
8条回答
  • 2020-11-27 15:45

    use this function:

        public static string ConvertDataTableToHTML(DataTable dt)
        {
            string html = "<table>";
            //add header row
            html += "<tr>";
            for(int i=0;i<dt.Columns.Count;i++)
                html+="<td>"+dt.Columns[i].ColumnName+"</td>";
            html += "</tr>";
            //add rows
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                html += "<tr>";
                for (int j = 0; j< dt.Columns.Count; j++)
                    html += "<td>" + dt.Rows[i][j].ToString() + "</td>";
                html += "</tr>";
            }
            html += "</table>";
            return html;
        }
    
    0 讨论(0)
  • 2020-11-27 15:46

    As per my understanding you need to show 3 tables data in one html table using asp.net with c#.

    I think best you just create one dataset with 3 DataTable object.

    Bind that dataset to GriView directly on page load.

    0 讨论(0)
提交回复
热议问题