How to access build html table to server side?
I would like to ask how can I access build html table to server side? Presently I am trying inner html, but that was not accessed to it.
Please help!
I would like to ask how can I access build html table to server side? Presently I am trying inner html, but that was not accessed to it.
Please help!
Â
Hi
You want to access html table to server side. First which technology do you use? Actually I know ASP.NET and C#. So i am doing answer by using this Technology. If you are use other technology then you can understand basic logic behind it and use it in your technology.
Code:
First of all you have to add runat="server" because you are fetching data from server.
In case you are accessing inner html table. Then you can access rows then cells and then for each cell you can access innerHtml Property.Â
Use the following code to create a table on server side:
Table table=new Table();Â
TableRow row=new TableRow();Â
TableCell cell=new TableCell();Â
cell.Text="your TD value Here";Â
row.cells.Add(cell);Â
table.rows.Add(row);Â
Form1.Control.Add(table);
Include this namespace: using System.Web.UI.HtmlControls;
Use the following code to access data from server:
Â
protected void Page_Load(object sender, EventArgs e)
{
           var str= tbl1.Rows[0].Cells[2].InnerHtml;
            lbl1.Text = str.ToString();
}
protected void Page_Load(object sender, EventArgs e)
{
          string str;
          for (int i = 0; i < tbl1.Rows.Count; i++)
       {
           for (int j = 0; j < tbl1.Rows.Cells.Count; j++)
           {
               str = tbl1.Rows.Cells[j].InnerHtml;
               lbl1.Text = lbl1.Text + " " + str;
           }
       }
   }