Solved

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

Posted on 2006-10-22
7
922 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
[X]
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
  • 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
Independent Software Vendors: 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!

 

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Finding the IIS version 5 38
Adding items to a C# list incrementally 5 64
Upgrade code from VS 2010 to VS 2015 7 33
Validation for Passport expiry in asp.net 2 15
Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

726 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