Solved

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

Posted on 2006-10-22
7
905 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now