Welcome Guest Search | Active Topics | Sign In | Register

slideview problems Options
r0k3t
Posted: Tuesday, July 3, 2007 1:21:03 PM
Rank: Member
Groups: Member

Joined: 7/3/2007
Posts: 21
Hi there,

I just started using EO but I am having a problem populating a slidemenu from a database.

This is what I tried as far as I understand.

1. Created the sql data source.
<asp:SqlDataSource ID="SqlDataSourceIndustry" runat="server" ConnectionString="Data Source=web2;Initial Catalog=TFGecommerce;Persist Security Info=True;User ID=xxxxxxx;Password=xxxxxx"
ProviderName="System.Data.SqlClient" SelectCommand="GetAllIndustries" SelectCommandType="StoredProcedure" OnSelecting="SqlDataSourceIndustry_Selecting">
</asp:SqlDataSource>

2. set the dataSourceId to the sql data source

<eo:SlideMenu ID="SlideMenu1" DataSourceID="SqlDataSourceIndustry" runat="server" ControlSkinID="Phthalo_Green" KeepExpandedOnClick="True"
Width="165px">

3. set the bindings for the submenu.

<SubMenu>
<Bindings>
<eo:DataBinding DataField="Name" Property="Text" />
</Bindings>
</SubMenu>


Note - I have also tried @Name instead of just Name based on the help docs.

Whatever I have tried it fails to populate the submenu... What I am missing.

Thanks
eo_support
Posted: Wednesday, July 4, 2007 2:30:52 PM
Rank: Administration
Groups: Administration

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

Thank you for posting your question here.
I tried this and I got the same result as you got. We are looking into this and will let you know as soon as we find out why.

Thanks.
eo_support
Posted: Wednesday, July 4, 2007 9:05:41 PM
Rank: Administration
Groups: Administration

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

You will not be able to populate a SlideMenu using SqlDataSource. The reason is because SlideMenu works with hierarchical data thus requires an IHierarchicalDataSource. Since SqlDataSource is not an IHierarchicalDataSource, so SlideMenu simply ignores it.

In order to populate the menu from database, you will need to use either a DataTable or a DataSet. These two pages explained these two methods in detail:

http://www.essentialobjects.com/ViewDoc.aspx?t=MenuCommon%2fDataBinding%2fpopulate_table.html
http://www.essentialobjects.com/ViewDoc.aspx?t=MenuCommon%2fDataBinding%2fpopulate_dataset.html

In both case the key is to define the hierarchical structure of the data.

Thanks
r0k3t
Posted: Thursday, July 5, 2007 6:22:55 AM
Rank: Member
Groups: Member

Joined: 7/3/2007
Posts: 21
Alright... Maybe I am a little dense. This is what I have attempted to do. It is probably easiest to just show you the code snippet.

sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["TFGecommerceConnectionString"].ConnectionString);
sqlConnection.Open();
SqlCommand selectAllIndustries = new SqlCommand("GetAllIndustires", sqlConnection);
selectAllIndustries.CommandType = CommandType.StoredProcedure;
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(selectAllIndustries);
da.Fill(ds);
SlideMenu1.DataSource = ds.Tables[0];
SlideMenu1.DataFields = "Name"; //Have also tried @Name
SlideMenu1.DataBind();

The code for the slideMenu looks like this.

<eo:MenuItem Text-Html="ind" NormalStyle-CssText="background-color:silver; "SelectedStyle-CssText="background-color:#0000c0;">
<SubMenu>
<Bindings>
<eo:DataBinding DataField="Name" Property="Text" />
</Bindings>
</SubMenu>
</eo:MenuItem>

I am totally missing something however as far as I can tell I have done things right. You said in both cases the key is to define the hierarchical structure of the data but in this case there is only one level so I am not sure what you mean by that.

Thanks for your help on this.
eo_support
Posted: Thursday, July 5, 2007 8:54:13 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,067
hi,

Actually your code is correct. What I was saying is for your instance, SqlDataSource won't work for SlideMenu. Which means you can not assign a SqlDataSource as SlideMenu's datasource. The reason is that SqlDataSource is not an IhirearchicalDataSource, which means our slideMenu only can work with datasource which inherits IHierarchicalDataSource interface. If you have a look at the SqlDataSource, it is SqlDataSource: DataSourceControl : Control, IDataSource, IListSource. For a better understanding IHierarchicalDataSource, you may have a look at this link:
http://msdn2.microsoft.com/en-us/library/system.web.ui.hierarchicaldatasourcecontrol.aspx

Thanks.
r0k3t
Posted: Friday, July 6, 2007 11:13:25 AM
Rank: Member
Groups: Member

Joined: 7/3/2007
Posts: 21
Hi

I have looked at the link you showed me. I understand what you are talking about however I still haven't been able to come up with a working solution.

how about an example that shows how to connect to a SQL database and create the dynamic slidmenu? I am a little frustrated with the help file at this point cause it isn't really a complete working example (no code behind page or anything that shows the creation of a datasource) and unless I am nuts I can't seem to find an example in the live demo that connects to a SQL database and creates a dynamic menu.


uhg....
eo_support
Posted: Friday, July 6, 2007 9:26:22 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,067
hi,

I will create an example for you based on your case. Can you PM your email address. I will zip the example and send to your mail box.

Thanks.
r0k3t
Posted: Tuesday, July 10, 2007 11:40:35 AM
Rank: Member
Groups: Member

Joined: 7/3/2007
Posts: 21
Hi all,

Well I finally got this thing to work. I looked at the example of the regular menu, sure they work mostly the same however I was stuck creating the sub menus. finally it dawned on me. I figured I would post this so that if anyone else has this problem they can see what to do. I always hate half finished threads cause someone figures it out and never says anything about the solution.

Cool!

protected void Page_Load(object sender, EventArgs e)
{
//first off create a new MenuItem.
EO.Web.MenuItem testMenuItem = new EO.Web.MenuItem("test");
//add that item to your slideMenu - you have to do this in order
//to assign it a dataSource.
SlideMenu1.Items.Add(testMenuItem);

//create the dataTable - you can do this any way you see fit,
//manually from a DB whatever.
DataTable mainTable = CreateDataTable(); //Just used to one from the live demo...

//assign the dataSource to the menuItem
testMenuItem.SubMenu.DataSource = mainTable;
//Set the DataFields
testMenuItem.SubMenu.DataFields = "City";

//Create a DataBinding, this is where I got the big clue on how to
//do this. - If you look at the examples where they have just a menu
//you only see how to add to the main menu. However once I saw this
//I figured that you could create an instance of subMenu just like you
//create an instance of DataBinding.
//
//Sure enough - you can, and once you do you can add a binding just like
//you could add a binding to the main slideMenu itself.
//
//Sounds easy once you know what you are doing...
EO.Web.DataBinding binding = new EO.Web.DataBinding();
binding.DataField = "WebSite";
binding.Property = "NavigateUrl";

testMenuItem.SubMenu.Bindings.Add(binding);
testMenuItem.SubMenu.DataBind();
}
eo_support
Posted: Tuesday, July 10, 2007 12:35:43 PM
Rank: Administration
Groups: Administration

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

Thanks for sharing! Glad to hear that you got it working. Please feel free to let us know if you have any more questions.

Thanks


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.