[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 946
  • Last Modified:

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

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
poogie22
Asked:
poogie22
  • 3
  • 3
1 Solution
 
jeebukarthikeyanCommented:
hi,

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

b u d d h a
0
 
poogie22Author Commented:
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
 
jeebukarthikeyanCommented:
hi,

cn u just tell what is the error

b u d d h a
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
poogie22Author Commented:
hi,
the error is " Name '_html' is not declared."
thanks.
indrani
0
 
jeebukarthikeyanCommented:
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
 
poogie22Author Commented:
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
 
codeclayCommented:
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now