Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
125
Dynamic URL string (using ICollection datasource)
posted

If I bind an ICollection datasource to WebExplorerBar, how can I set the url properties so that the urls are dynamically constructed depending on the IDs or properties of the objects within the collection?

I have an ICollection datasource of List of Books which contain List of Chapters which I bound to WebExplorerBar in PageLoad event.  (I copied the WebExplorerBarDataBinding example). 

I was able to set the DataMember and TextField for ExplorerBarItemBinding (again using the example).
<ig:ExplorerBarItemBinding DataMember="Book" TextField="Title" />
<ig:ExplorerBarItemBinding DataMember="Chapter" TextField="Title" />

However I am not sure how I can set the url of the items which will vary according to the ids of the book and chapters. Book and Chapter class have BookID and ChapterID properties respectively.

This is how I'd like the url of the each item to be constructed. Can I somehow use NavigateUrlFormatString? I guess I could construct the url in the Book and Chapter classes and map it to the NavigateURLField but I don't want to store a url in business objects.

Book 1 : default.aspx?bookId=1
  - Chapter 1 : default.aspx?bookId=1&chapterId=1
  - Chapter 2 : default.aspx?bookId=1&chapterId=2
Book 2 : default.aspx?bookId=2
  - Chapter 1 : default.aspx?bookId=2&chapterId=1
  - Chapter 2 : default.aspx?bookId=2&chapterId=2

Thanks in advance!

Parents
No Data
Reply
  • 3726
    Verified Answer
    posted

    You have to set the NavigateUrlFormatString of an explorer bar item bing to something like:

    NavigateUrlFormatString="default.aspx?bookId={0}&chapterId={1}"

    you have to set the NavigateUrlField to NavigateUrlField="bookId, chapterId" which is comma separated list of properties of the binded object that will be queried to retrieve the data. (If you are binding to "Book" business objects, then bookId and chapterId must be properties of that business object.) Then the explorer bar item NavigateUrl is set like string.Format(formatString, propertyValuesArray); which will yield the final URL that you want to construct.

    Let me know was this helpful.

Children
No Data