Welcome Guest Search | Active Topics | Sign In | Register

How to Navigate to URL associated with Dynamically created Menu? Options
Malkit
Posted: Monday, March 12, 2012 12:14:46 PM
Rank: Newbie
Groups: Member

Joined: 3/11/2012
Posts: 4
hi team,
I have following table in my database.


where menuId is autogenerated and menuParentID carries the id of root menu and menuNavigation
is the NavigationURL of the menu.

i have written following code using stored procedure to fetch the data from the database.
Code: C#
protected void Page_Load(object sender, EventArgs e)
    {
        DataSet mainDs = CreateDataSet();
        Menu1.DataSource = mainDs;
        EO.Web.DataBinding binding = new EO.Web.DataBinding();
        binding.DataField = "menuDescription";
        
        binding.Property = "Text-Html";
        
        Menu1.Bindings.Add(binding);

        
        Menu1.DataBind();

        
    }
    private DataSet CreateDataSet()
{
        //------------------------
    string connstr = Convert.ToString(ConfigurationManager.ConnectionStrings["projackerConnectionString"].ConnectionString);
    SqlConnection vcon = new SqlConnection(connstr);
    vcon.Open();
        DataSet ds = new DataSet();
    SqlCommand cmd = new SqlCommand();
    cmd.Connection = vcon;
    cmd.CommandText = "[spFetchAllFromMenuMaster]";//this is my stored procedure name
    cmd.CommandType = CommandType.StoredProcedure;

    SqlDataAdapter adtp = new SqlDataAdapter(cmd);
    
    adtp.Fill(ds,"tblMenuMaster");
    vcon.Close();
    DataColumn menuParentId = ds.Tables["tblMenuMaster"].Columns["menuParentId"];
    DataColumn menuId = ds.Tables["tblMenuMaster"].Columns["menuId"];
    
    DataRelation r = ds.Relations.Add(menuId,menuParentId);
    r.Nested = true;
    return ds;

}


now, it generates the Desired output i.e Menu which looks like this.


but, my problem Brick wall is that, when user clicks on any menu item, one should be forwarded to the page/url specified in menuNavigation field in table.d'oh!

-Thanks.
eo_support
Posted: Monday, March 12, 2012 12:20:15 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Can you explain WHY you think the menu should forward to the page/Url specified in menuNavigation field? Did you do anything or write any code to make that happen?

Thanks
Malkit
Posted: Monday, March 12, 2012 12:30:23 PM
Rank: Newbie
Groups: Member

Joined: 3/11/2012
Posts: 4
oh good to see reply so quick..

well i think so...bcz i believe thats what a menu thing is meant for....i.e when user selects a menu listed item, then he should be able to see that page mentioned in navigation field....
no, i haven't written any code...and could have written if something like this could have possible....
Code: C#
EO.Web.DataBinding binding = new EO.Web.DataBinding();
        binding.DataField = "menuDescription";
bingding.Navigation="menuNavigation";
;)
eo_support
Posted: Monday, March 12, 2012 12:50:24 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
You should work on that first. It's a bit off for you to ask why things are not working before actually trying to do anything to make it work. In the future we will ignore such questions.

Thanks!
Malkit
Posted: Monday, March 12, 2012 1:58:45 PM
Rank: Newbie
Groups: Member

Joined: 3/11/2012
Posts: 4
eo_support wrote:
You should work on that first. It's a bit off for you to ask why things are not working before actually trying to do anything to make it work. In the future we will ignore such questions.

Thanks!


so i worked....nd i fixed it as well.....Visual Studio's Menu control played good role in solving this problem.
and yes...thanks for your kind Support.

Thanks!
Malkit
Posted: Tuesday, March 13, 2012 3:29:52 AM
Rank: Newbie
Groups: Member

Joined: 3/11/2012
Posts: 4
Finally, Working according to my requirement....now navigating to URL specified...
all i was missing last time is one single line of code. i.e
Code: C#
Menu1.DataFields="menuDescription";




You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.