Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to display data in HTML Table?Html table works same as Gridview for displaying data from the database.
Posted

http://www.w3schools.com/ado/ado_display.asp[^]

May this link usefull to u.......:)
 
Share this answer
 
When GridView Rendered, it also produce HTML Table script. you can accessfrom javascript as
var tableGrid=document.getElementById('<%=gridID.ClientID%>');
 
Share this answer
 
Comments
Tech Code Freak 6-Feb-12 6:37am    
5up!
Hi,

HtmlTable [^] is server side control used to display standard html table. It is consist of HTMLTableRows HTMLTableCells. If you don't need it don't use it. That's my advice. Use GridView instead. With gridView you have full support on server side (various events) to customize whatever you want and with css you can format it as you like... :)
 
Share this answer
 
Comments
Madhuri2012 6-Feb-12 2:48am    
But with Gridview it is slow process.
i want HtmlTable for it for faster process.
Martin Arapovic 6-Feb-12 9:45am    
How you mean grid view is slower? I think that it's pretty much the same thing.
If you need to use HtmlTable the you need to query your data and build your table dynamically.
GridView works on the same way, and gives you more features (Sorting, Paging, CSS formatting is easier...) then simple HTMLtable.
Tech Code Freak 6-Feb-12 6:37am    
5up!
Take html table control on .aspx page and write below code on .cs page.
C#
DataTable DT = new DataTable();
           HtmlTableRow TR;
           HtmlTableCell TD;

           if (DT.Rows.Count>0)
           {
           TR = new HtmlTableRow();
           TR.Attributes.Add("class", "tblHeading");
           TD = new HtmlTableCell();
           TD.InnerHtml = " Branch Code";
           TD.Align = "Left";
           TD.Style[HtmlTextWriterStyle.FontSize] = "11px";
           TR.Cells.Add(TD);
           tblRpt.Rows.Add(TR);

           TD = new HtmlTableCell();
           TD.InnerHtml = " Branch Name";
           TD.Align = "Left";
           TD.Style[HtmlTextWriterStyle.FontSize] = "11px";
           TR.Cells.Add(TD);
           tblRpt.Rows.Add(TR);

           TD = new HtmlTableCell();
           TD.InnerHtml = " Branch Address";
           TD.Align = "Left";
           TD.Style[HtmlTextWriterStyle.FontSize] = "11px";
           TR.Cells.Add(TD);
           tblRpt.Rows.Add(TR);

           TD = new HtmlTableCell();
           TD.InnerHtml = " Branch City";
           TD.Align = "Left";
           TD.Style[HtmlTextWriterStyle.FontSize] = "11px";
           TR.Cells.Add(TD);
           tblRpt.Rows.Add(TR);

           TD = new HtmlTableCell();
           TD.InnerHtml = " Branch State";
           TD.Align = "Left";
           TD.Style[HtmlTextWriterStyle.FontSize] = "11px";
           TR.Cells.Add(TD);
           tblRpt.Rows.Add(TR);
       }
 
Share this answer
 
v2
Comments
Tech Code Freak 6-Feb-12 6:37am    
5up!
Madhuri2012 6-Feb-12 7:02am    
I dont know how to apply it.Please provide me information if it is possible.
thanks.
Career Web Helper 7-Feb-12 7:51am    
hello Madhuri take <table id="tblRpt" runat="server" width="97%" height="10%" class="tblDisplay"></table> in .aspx page
and write above code on .aspx.cs page,u will get table with heading as Branch Code,Branch Name ..etc and then by iterating through rows of DT u will get data and display it lly..
Member 13704761 6-Mar-18 5:02am    
this code is not working

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900