I saw the example for binding to a static XML file but that doesn't really help me since I need a menu that reacts to what the user subscribes to (in other words, not everybody sees the same menu). I can create an XML document on the fly from a stored procedure but when I try to bind it I get 'System.Data.Common.DataRecordInternal' displayed on my page instead of a menu. I set RootDatamember in the object properties but I'm sure there is more I need to do but I don't know how. I tried to edit databindings from the context menu but VS2008 froze on me. Also, I'm returning an XML type in a datareader. Can I bind to the datareader or do I need to extract the XML from the datareader first?
Hello,would you be able to provide a sample project that we can evaluate and try to provide the best solution for you. It can be providing just a single statically saved XML bytes, jsut to illustrate your approach. There is no need to provide full feature demo.
There is an option to upload a file here -> "Options" tab when you are replying. you will see the file upload option.
Meanwhile you can try to first extract the full XML before binding.
I don't have a sample project to upload, I only have the existing project that I am trying to add this to and it is huge. Here is what I have in the page itself:
<
ig:WebDataMenu ID="infMainLeftMenu" runat="server" RootDataMember="Header">
</
ig:WebDataMenu>
asp:ScriptManager ID="ScriptManager1" runat="server">
asp:ScriptManager>
This is what I have in code behind:
Dim dr2 As SqlDataReader = objLeftMenu.getMainLeftMenu(m_SessionID, m_ClientID, m_uID, m_fclt)
Dim strXML As Xml = dr2(0)
infMainLeftMenu.DataSource = strXML
'infMainLeftMenu.DataBindings("textValue") = "ItemName"
infMainLeftMenu.DataBind()
dr2 =
Nothing
This what strXML contains:
<Headers><Header HeaderID="SEARCH" HeaderName="Search"><Item><ItemID>ACCSRCH</ItemID><ItemName>Account Search</ItemName><Enabled>1</Enabled></Item><Item><ItemID>PRACSRCH</ItemID><ItemName>Practioner Search</ItemName><Enabled>1</Enabled></Item><Item><ItemID>CONSRCH</ItemID><ItemName>Contact Search</ItemName><Enabled>1</Enabled></Item></Header></Headers>
and this is what I see in the page source after I run the page:
<input type="hidden" id="LeftMenu1_infMainLeftMenu_clientState" name="LeftMenu1_infMainLeftMenu_clientState" /><div id="LeftMenu1_infMainLeftMenu" class="ig_Control igdm_ControlVertical " id="LeftMenu1_infMainLeftMenu" style="display:block;"> <ul class="igdm_MenuGroupVerticalRoot ">
</ul></div>
I see nothing at all in the page now.
Hello,
Thank you for your sample. Meanwhile what I see is that provided XML structure is not suitable to bind to Hiearachical control. In order to bind XML structure to a control in ASP.NET you need to have the properties as Attributes, not as child elements. So instead of:
<Item> <ItemID>ACCSRCH</ItemID> <ItemName>Account Search</ItemName> <Enabled>1</Enabled></Item>
You shall have:
<Item ItemID="ACCSRCH" ItemName="Account Search" Enabled="1"></Item>
Can you try rearranging your XML with attributes, while we are investigating how to bind it.
And keep tracking this thread as I will update any info here.
How does this look?
<Headers><Header HeaderID="SEARCH" HeaderName="Search"> <Item ItemID="ACCSRCH" ItemName="Account Search" URL="AccSearch.aspx?SessionID=6F9619FF_8B86_D011_B42D_00C04FC964FF&fclt=no"/> <Item ItemID="PRACSRCH" ItemName="Practitioner Search" URL="PractSearch.aspx?SessionID=6F9619FF_8B86_D011_B42D_00C04FC964FF&fclt=no"/> <Item ItemID="CONSRCH" ItemName="Contact Search" URL="ContactSearch.aspx?SessionID=6F9619FF_8B86_D011_B42D_00C04FC964FF&fclt=no"/></Header><Header HeaderID="MYSEARCH" HeaderName="My Searches"> <Item ItemID="SRCH346" ItemName="All BTs mult Counties" URL="AccSearchResults.aspx?SessionID=6F9619FF_8B86_D011_B42D_00C04FC964FF&fclt=no&queryID=346"/> <Item ItemID="SRCH345" ItemName="All BTs mult MSAs" URL="AccSearchResults.aspx?SessionID=6F9619FF_8B86_D011_B42D_00C04FC964FF&fclt=no&queryID=345"/> <Item ItemID="SRCH344" ItemName="All BTs Baton Rouge MSA" URL="AccSearchResults.aspx?SessionID=6F9619FF_8B86_D011_B42D_00C04FC964FF&fclt=no&queryID=344"/></Header><Header HeaderID="MYACCTS" HeaderName="My Accounts"> <Item ItemID="ACCT1578" ItemName="(removed), Philadelphia, PA, Integrated Healthcare Network" URL="Profiles.aspx?SessionID=6F9619FF_8B86_D011_B42D_00C04FC964FF&fclt=no&&fid=G21TGB&bu=NW"/> <Item ItemID="ACCT1577" ItemName="(removed), Boston, MA, HMO" URL="Profiles.aspx?SessionID=6F9619FF_8B86_D011_B42D_00C04FC964FF&fclt=no&&fid=G001Q8&bu=HM"/> <Item ItemID="ACCT1576" ItemName="(removed), Farmington, CT, HMO" URL="Profiles.aspx?SessionID=6F9619FF_8B86_D011_B42D_00C04FC964FF&fclt=no&&fid=G11251&bu=HM"/> <Item ItemID="ACCT1574" ItemName="(removed), Warrendale, PA, Group Purchasing Org" URL="Profiles.aspx?SessionID=6F9619FF_8B86_D011_B42D_00C04FC964FF&fclt=no&&fid=G11H73&bu=GP"/> <Item ItemID="ACCT1573" ItemName="(removed), Abington, PA, Hospital" URL="Profiles.aspx?SessionID=6F9619FF_8B86_D011_B42D_00C04FC964FF&fclt=no&&fid=G00KYE&bu=HO"/></Header><Header HeaderID="SAMPLE" HeaderName="Sample of disabled"> <Item ItemID="SAMP346" ItemName="Sample 1" URL="BLOCKED SCRIPTShowAlert('You did not purchase this product!')"/></Header></Headers>
A Header will be the category while items will be the links below them. I am hoping that my last example will work (javascript instead of a link).