Click here to Skip to main content
15,881,715 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralChristian why you are abusing racially with your answer Pin
Mogamboo_Khush_Hua24-Aug-09 20:37
Mogamboo_Khush_Hua24-Aug-09 20:37 
Rant... one of the hordes of unskilled third world programmers ripping off western companies ... Pin
AprNgp24-Aug-09 23:26
AprNgp24-Aug-09 23:26 
Answer[Message Deleted] Pin
haleemasher24-Aug-09 19:45
haleemasher24-Aug-09 19:45 
GeneralRe: login page Pin
N a v a n e e t h24-Aug-09 20:49
N a v a n e e t h24-Aug-09 20:49 
GeneralRe: login page Pin
Ashfield24-Aug-09 21:09
Ashfield24-Aug-09 21:09 
Questiondynamic menu... Pin
RajpootRohan24-Aug-09 19:08
professionalRajpootRohan24-Aug-09 19:08 
AnswerRe: dynamic menu... Pin
Christian Graus24-Aug-09 19:12
protectorChristian Graus24-Aug-09 19:12 
GeneralRe: dynamic menu... Pin
RajpootRohan24-Aug-09 19:30
professionalRajpootRohan24-Aug-09 19:30 
Thank you for replying. I did like this:

using System;
using System.Configuration;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page 
{
    string name;
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!Page.IsPostBack)
        {
            populate_menu();
        }
    }

    DataSet GetMenuData()
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["newcon"].ConnectionString);
        SqlCommand cmd = new SqlCommand();
        ArrayList arl = new ArrayList();
        cmd.Connection = con;
        cmd.CommandText = "select * from CATEGORY ";
        SqlDataAdapter sda = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        cmd.Connection.Open();
        sda.Fill(ds, "CATEGORY");
        return ds;
    }

    public void populate_menu()
    {
        DataSet ds = GetMenuData();
        foreach(DataRow drow in ds.Tables["CATEGORY"].Rows)
        {
            MenuItem masteritem = new MenuItem((string)drow["category_name"]);
            name = masteritem.Text;
            get_id();
            int par_id = Convert.ToInt32 (ViewState["p_id"]);
            if (par_id == 0)
            {
                Menu1.Items.Add(masteritem);
            }
            else
            {
                //masteritem.ChildItems.Add(masteritem);
                Menu1.Items.Add(masteritem);
            }
        }
    }

    public void get_id()
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["newcon"].ConnectionString);
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = con;
        cmd.CommandText = "select parent_id from CATEGORY where category_name='"+name+"'";
        cmd.Connection.Open();
        int pa_id = Convert.ToInt32(cmd.ExecuteScalar());
        ViewState["p_id"] = pa_id;

    }
}


From this I am getting output like this:

Catering
Plastics
Glassware

cheers,
sneha

GeneralRe: dynamic menu... Pin
Christian Graus24-Aug-09 19:32
protectorChristian Graus24-Aug-09 19:32 
GeneralRe: dynamic menu... Pin
RajpootRohan24-Aug-09 21:32
professionalRajpootRohan24-Aug-09 21:32 
QuestionCannot implicitly convert type 'string' to 'System.Web.UI.WebControls.TextBox' Pin
haleemasher24-Aug-09 18:21
haleemasher24-Aug-09 18:21 
AnswerRe: Cannot implicitly convert type 'string' to 'System.Web.UI.WebControls.TextBox' Pin
Abhijit Jana24-Aug-09 18:34
professionalAbhijit Jana24-Aug-09 18:34 
GeneralRe: Cannot implicitly convert type 'string' to 'System.Web.UI.WebControls.TextBox' Pin
haleemasher24-Aug-09 18:46
haleemasher24-Aug-09 18:46 
GeneralRe: Cannot implicitly convert type 'string' to 'System.Web.UI.WebControls.TextBox' Pin
Sendilkumar.M24-Aug-09 19:28
Sendilkumar.M24-Aug-09 19:28 
AnswerRe: Cannot implicitly convert type 'string' to 'System.Web.UI.WebControls.TextBox' Pin
ali_reza_zareian24-Aug-09 18:46
ali_reza_zareian24-Aug-09 18:46 
GeneralRe: Cannot implicitly convert type 'string' to 'System.Web.UI.WebControls.TextBox' Pin
haleemasher24-Aug-09 18:54
haleemasher24-Aug-09 18:54 
AnswerRe: Cannot implicitly convert type 'string' to 'System.Web.UI.WebControls.TextBox' Pin
Christian Graus24-Aug-09 19:01
protectorChristian Graus24-Aug-09 19:01 
AnswerRe: Cannot implicitly convert type 'string' to 'System.Web.UI.WebControls.TextBox' Pin
padmanabhan N24-Aug-09 19:04
padmanabhan N24-Aug-09 19:04 
GeneralRe: Cannot implicitly convert type 'string' to 'System.Web.UI.WebControls.TextBox' Pin
Christian Graus24-Aug-09 19:10
protectorChristian Graus24-Aug-09 19:10 
AnswerRe: Cannot implicitly convert type 'string' to 'System.Web.UI.WebControls.TextBox' Pin
harshangrana24-Aug-09 19:54
harshangrana24-Aug-09 19:54 
QuestionA page can have only one server-side Form tag. Pin
haleemasher24-Aug-09 18:15
haleemasher24-Aug-09 18:15 
AnswerRe: A page can have only one server-side Form tag. Pin
Abhijit Jana24-Aug-09 18:31
professionalAbhijit Jana24-Aug-09 18:31 
AnswerRe: A page can have only one server-side Form tag. Pin
Christian Graus24-Aug-09 19:14
protectorChristian Graus24-Aug-09 19:14 
AnswerRe: A page can have only one server-side Form tag. Pin
Sendilkumar.M24-Aug-09 19:31
Sendilkumar.M24-Aug-09 19:31 
QuestionHow to create exe file of C# web project? Pin
nudma24-Aug-09 18:15
nudma24-Aug-09 18:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.