Solved

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

Posted on 2006-10-22
7
898 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 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