 |
|
 |
Hi Everyone! just want to find out if someone has tried the BindMenu. I did and it seem not to work with Internet Explorer 8. Can someone verifer for me?
Thanks and best regards!
|
| Sign In·View Thread·PermaLink | 1.50/5 |
|
|
|
 |
 | me 2  anhduongxanh | 17:54 2 Apr '09 |
|
|
 |
|
 |
nice idea. 2 questions:
1. When you have sub-sub-sub link, how will it look? The link will be placed into SubSubSubCategory table? To make logic, you have to generate new tables in DB, haven't you? Example: Home >2008 >Books >Articles >SomeLink
Not very good.
2. How do you change links? Directly in DB?
Point of view: Better to make all in one table, example - <b>dbo.SiteMap</b>, with default columns for xml sitemap PLUS [Id] - id of link element, is a KEY [Id_2] contain id of id for sub element [Id_3] contaain id of id of id for sub sub element. Then Id_2 MUST be 0. ... and so on
Example, when Id_x == 0, then it doesn't belong to sub directory Id Id_2 Id_3 Id_4 [Title] [Url] [Description] [Comments] [idRole] 1 0 0 0 Home ~/ Bla-bla root 1 2 1 0 0 2008 ~/2008 bla-bla '08 year 1 4 0 2 0 Books ~/2008/Books "" "" 1 3 0 2 0 Articles ~/2008/Articles "" "" 1 4 0 0 3 SomeLink ~/2008/Articles/Lnk "" "" 1
Where idRole is RELATION to <b>dbo.aspnet_Roles</b> or any other role table of your DB where idRole == 1 is Public.
Som you will gain some features and bugs if you follow this way: + as you see, it looks like matrix, and so you can include each row into several submenus. Sitemap never provide this feature + you can extent and make it deeper how it is needed + simple to change - easy to break without nicely created interface for managing tables. - you have to provide logic for cascade delete and cascade modify.
__ Yurii
|
| Sign In·View Thread·PermaLink | 1.50/5 |
|
|
|
 |
 | Layout  Velvet Saunders | 6:27 22 Oct '08 |
|
|
 |
|
 |
Yes, you can make menus to be displayed horizontal and vertical.
There is a property for menus called as Orientation set them to horizontal or vertical.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Do you by any chance have the C# code for this? I have been trying to changes the lines to C# and I am stuck on this line:
Dim mNode As New MenuItem(CType(categoryRow("CatName"), String), "", "", "~/DetailView.aspx?CatID=" + CType(categoryRow("CatId"), String), "_parent")
These are few of the things I tried doing:
MenuItem mNode = new MenuItem(Convert.ToString(categoryRow["CatName"], String), "", "", "~/DetailView.aspx?CatID=" + Convert.ToString(categoryRow["CatId"], String), "_parent");
MenuItem mNode = new MenuItem(categoryRow["CatName"].ToString, "", "", "~/DetailView.aspx?CatID=" + categoryRow["CatId"].ToString, "_parent");
This is the error I get in both cases:
Compiler Error Message: CS0029: Cannot implicitly convert type 'string' to 'int'
Thank you.
|
| Sign In·View Thread·PermaLink | 1.00/5 |
|
|
|
 |
|
 |
Here is the code in C#.
MenuItem mNode = new MenuItem (Convert.ToString(categoryRow["CatName"]),"","", "~/DetailView.aspx?CatID="+Convert.ToString(categoryRow["CatId"]),"_parent");
it seems you have passed an extra parameter(i.e string) to Convert.ToString() method.
Happy Programming.
|
| Sign In·View Thread·PermaLink | 2.00/5 |
|
|
|
 |
|
 |
Hi Ravi, Thank you so much for your reply.
However, I am still getting the error:
CS0029: Cannot implicitly convert type 'string' to 'int'
I did replace the line with the code that you had sent me and it still doesn't work.
private void BindMenu() { String connectionString = crafters.DbConnectionString; SqlConnection con = new SqlConnection(connectionString); SqlDataAdapter dadCategories = new SqlDataAdapter("SELECT CatId,CatName FROM Category order by CatName", con); SqlDataAdapter dadSubCat = new SqlDataAdapter("SELECT SubCatId,CatId,SubCatName FROM SubCategory order by SubCatName", con);
DataSet dsCat = new DataSet(); using (con) { con.Open(); dadCategories.Fill(dsCat, "Category"); dadSubCat.Fill(dsCat, "SubCategory"); } DataColumn parentColumn = dsCat.Tables["Category"].Columns["CatID"]; DataColumn childColumn = dsCat.Tables["SubCategory"].Columns["CatId"]; DataRelation relation = new System.Data.DataRelation("Children", parentColumn, childColumn); dsCat.Relations.Add(relation);
int count = 0; foreach(DataRow[] categoryRow in dsCat.Tables["Category"].Rows) { MenuItem mNode = new MenuItem(Convert.ToString(categoryRow["CatName"]), "", "", "~/DetailView.aspx?CatID=" + Convert.ToString(categoryRow["CatId"]), "_parent"); Menu1.Items.Add(mNode);
}
I really need your help on this. Thank you in advance.
|
| Sign In·View Thread·PermaLink | 5.00/5 |
|
|
|
 |
|
 |
Try this complete code. I have tested this code it is working fine.
internal void BindMenu() { string cs = WebConfigurationManager.ConnectionStrings["DatabaseConnectionString1"].ConnectionString; SqlConnection con = new SqlConnection(cs); SqlDataAdapter dadCategories = new SqlDataAdapter("SELECT CatId,CatName FROM Category order by CatName", con); SqlDataAdapter dadSubCat = new SqlDataAdapter("SELECT SubCatId,CatId,SubCatName FROM SubCategory order by SubCatName", con);
DataSet dsCat = new DataSet(); using (con) { con.Open(); dadCategories.Fill(dsCat, "Category"); dadSubCat.Fill(dsCat, "SubCategory"); }
dsCat.Relations.Add("Children", dsCat.Tables["Category"].Columns["CatId"], dsCat.Tables["SubCategory"].Columns["CatId"]); int count = 0; foreach (DataRow categoryRow in dsCat.Tables["Category"].Rows) { MenuItem mNode = new MenuItem(Convert.ToString(categoryRow["CatName"]), "", "", "~/DetailView.aspx?CatID=" + Convert.ToString(categoryRow["CatId"]), "_parent"); Menu1.Items.Add(mNode);
DataRow[] subCatRows = categoryRow.GetChildRows("Children"); foreach (DataRow row in subCatRows) { string subCatName = Convert.ToString(row["SubCatName"]); MenuItem subCatItems = new MenuItem(subCatName, "", "", "~/DetailView.aspx?CatID=" + Convert.ToString(row["CatId"]) + "&SubCatID=" + Convert.ToString(row["SubCatId"]), "_parent"); Menu1.Items[count].ChildItems.Add(subCatItems); } count = count + 1; } }
Happy Programming 
|
| Sign In·View Thread·PermaLink | 4.00/5 |
|
|
|
 |
|
 |
String connectionString = "Initial Catalog=mydata; Data Source=GOD-E4462345A8F; User Id=sa;Password=deepika"; SqlConnection con = new SqlConnection(connectionString); SqlDataAdapter dadCategories = new SqlDataAdapter("SELECT * FROM menu", con); SqlDataAdapter dadSubCat = new SqlDataAdapter("SELECT * FROM menudata", con); // Add the DataTables to the DataSet DataSet dsCat = new DataSet(); using (con) { con.Open(); dadCategories.Fill(dsCat,"MENU"); dadSubCat.Fill(dsCat,"menudata"); int count = 0; foreach (DataRow categoryRow in dsCat.Tables["menu"].Rows) { MenuItem mNode = new MenuItem(Convert.ToString(categoryRow[0] )); Menu1.Items.Add(mNode); } foreach (DataRow categoryRows in dsCat.Tables["menudata"].Rows ) { int i,p; i= dsCat.Tables[1].Columns .Count; p=1; while (p <i) { MenuItem mNodes = new MenuItem(Convert.ToString(categoryRows[p])); Menu1.Items[count].ChildItems.Add(mNodes); p++; } count++; } }
|
| Sign In·View Thread·PermaLink | 3.00/5 |
|
|
|
 |
|