Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

making a dynamic html table in code behind (vb.net)

Posted on 2006-10-22
7
916 Views
Last Modified: 2012-06-21
i am creating a menu in the code behind and i have 2 functions for it 1)main menu()  function and 2)sub menu() function

my main menu function retorns value  "Menu1=new Array('Folder 1','0','',1,16,170);"

then my sub menu function starts and finds submenu for  - Folder 1
and returns value  "Menu1_1_1=new Array('folder3','2','',0,16,170);"  the submenu function continues next time if it finds submenu for folder2
and returns value  "Menu1_1=new Array('folder2','1','',1,16,170);Menu1_1_1=new Array('folder3','2','',0,16,170);"

my question is what should i write in my vb.net code behind page so that i can show these folder and subfolder in a vertical menu format.if i need to make an html table please give me the codes.
mine is an asp.net 2003 application.
Thanks
0
Comment
Question by:poogie22
  • 3
  • 3
7 Comments
 
LVL 13

Expert Comment

by:jeebukarthikeyan
ID: 17783504
hi,

if u want to create html behind the codes then stringbuilder is best for that

b u d d h a
0
 

Author Comment

by:poogie22
ID: 17783519
can u give me the codes that i have to write ,i have given above the output that i will be getting.
i have come across the codes
if (dataSource != null)
//                  {
//                        _html.Append("<ul>");
//
//                        foreach (object dataObject in dataSource)
//                        {
//
//                              _html.Append("<li>");
//
//                              _html.Append(dataObject.ToString());
//
//                              _html.Append("</li>");
//
//                        }
//
//                        _html.Append("</ul>");
//
//                  }             
            }

but  when i write in my code behind i am getting error in _html .please help.
0
 
LVL 13

Expert Comment

by:jeebukarthikeyan
ID: 17783585
hi,

cn u just tell what is the error

b u d d h a
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:poogie22
ID: 17786441
hi,
the error is " Name '_html' is not declared."
thanks.
indrani
0
 
LVL 13

Accepted Solution

by:
jeebukarthikeyan earned 500 total points
ID: 17786661
hi,

first declare the '_html'
i hope it must be a stringbuilder

first declare it

stringbuilder _html=new strinbuilder();
_html.Apped('......');


b u d d h a
0
 

Author Comment

by:poogie22
ID: 17794931
how to place the main menu and the sub menu in the string builder,so that it shows a vertical menu  my hirarchi should be folder1 then its submenu folder2 then its submenu folder3.
thanks
0
 
LVL 9

Expert Comment

by:codeclay
ID: 17938997
This is how I made a dynamic table from code behind .
private void MakeTable()
    {
            DataSet dsTypes=new DataSet();
                  DataSet dsSubCat=new DataSet();
                  DataSet dsSSubCat=new DataSet();
                  DataSet dsItems=new DataSet();
                  DataSet dsRate=new DataSet();
                  ArrayList arTypes=new ArrayList();
                  ArrayList arsubCat=new ArrayList ();
                  HtmlTableRow tr;
                  HtmlTableCell td;
                  HtmlImage img;
                  HtmlInputText inp;
                  HtmlInputHidden inpH;
                  int i=0;
                  int g=0;
                  int j=0;
                  int gr=0;
                  dsTypes=//Get Dataset
            foreach(DataRow drType in dsTypes.Tables[0].Rows)
                  {      
                        dsSubCat=//Get Dataset
                        arsubCat=//Get ArrayList
                        foreach(DataRow dr in dsSubCat.Tables[0].Rows)
                        {
                              
                              foreach(string strSubId in arsubCat)
                              {
                                    tr= new HtmlTableRow();
                                    td=new HtmlTableCell();

                                    td.ColSpan=5;
                                    td.Width="50%";
                                    td.Align="Left";
                                    td.InnerText=dr[2].ToString();
                                    td.Style.Add("font-family","BankGothic Md BT, Verdana, Arial, sans-serif");
                                    td.Style.Add("font-size","small");
                                    tr.Cells.Add(td);
                                    
                                    img= new HtmlImage();
                                    img.Src="../image.gif";
                                    img.Border=0;
                                    
                                    td=new HtmlTableCell();
                                    td.Align="Right";
                                    td.VAlign="Bottom";
                                    td.ColSpan=5;
                                    td.Controls.Add(img);

                                    tr.BgColor=drType[3].ToString();//Header Color
                                    tr.Cells.Add(td);
                                    tr.Height="25 px";
                              
                                    tblContainer.Rows.Add(tr);
                                    dsSSubCat=//Get Sub Dataset ..May be you can do some further looping
                                          
                                          
                    }
                    tblContainer.Rows.Add(tr);
                }
            }

Where tblContainer is a table in the aspx page with attribute "runat" set to "server" .
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question