There a number of free/cheap menu packages available for .NET that
will save you the work.    Checkout
http://www.asp.net/ControlGallery/default.aspx?Category=32&tabindex=2
for an idea.

But if you want to do this yourself, start with web user control, add
a repeater control, then add a hyperlink to the repeater's item
template, like so...

<%@ Control Language="vb" AutoEventWireup="false"
Codebehind="hm.ascx.vb" Inherits="Playground.hm"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5"; %>
<asp:Repeater id="Repeater1" runat="server">
<HeaderTemplate><table><tr></HeaderTemplate>
<ItemTemplate>
        <td><asp:HyperLink ID="mnuItem" Runat="server"></asp:HyperLink></td>

</ItemTemplate>
<FooterTemplate>
</tr></table>
</FooterTemplate>
</asp:Repeater>

Then you simply bind it to the menu items returned from your stored proc.

Repeater1.DataSource =
SomeFunctionThatCallsYourStoredProcAndReturnsAReaderOrDataTable()
Repeater1.DataBind()

Add a ItemDataBound event handler to set your menu hyperlinks. For example,

    Private Sub Repeater1_ItemDataBound(ByVal sender As Object, ByVal
e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles
Repeater1.ItemDataBound
        Dim hl As HyperLink
        Dim dr As DataRow
        If e.Item.ItemType = ListItemType.AlternatingItem Or
e.Item.ItemType = ListItemType.Item Then
            hl = e.Item.FindControl("mnuItem")
            dr = e.Item.DataItem
            hl.Text = dr("Text")
            hl.NavigateUrl = Request.Url.LocalPath & "?mID=" & dr("ID")
        End If
    End Sub

You'll want to change the NavigateURL obviously and add some styling
to the menu,  but this is the basic way to create a dynamic horizontal
menu.

-- 
Dean Fiala
Very Practical Software, Inc
http://www.vpsw.com


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to