views:

1594

answers:

1

I have an ASP.NET DataGrid that I am trying to add a HoverMenu Extender to. The grid markup is as follows:

<asp:datagrid id="dgrExisting" runat="server" autogeneratecolumns="false" cssclass="FormattedTable" onitemcommand="dgrExisting_ItemCommand" onitemdatabound="dgrExisting_ItemDataBound">
                <headerstyle cssclass="FormattedTableHeader">
                <alternatingitemstyle cssclass="FormattedTableAltRow"></alternatingitemstyle>
                <columns>
                    <asp:boundcolumn datafield="UrlId" visible="false"></asp:boundcolumn>
                    <asp:boundcolumn datafield="MonitorUrl" headertext="Url"></asp:boundcolumn>
                    <asp:boundcolumn datafield="LastChecked" headertext="Last Checked"></asp:boundcolumn>
                    <asp:boundcolumn datafield="NextCheck" headertext="Next Check" visible="false"></asp:boundcolumn>
                    <asp:boundcolumn datafield="LastLoadTime" headertext="Last Load Time&lt;br&gt;&lt;/asp&gt;(Milliseconds)">
                    <asp:boundcolumn datafield="LastStatus" headertext="Last Status"></asp:boundcolumn>
                    <asp:templatecolumn>
                        <itemtemplate>
                            <asp:panel id="pnlPopupMenu" runat="server">
                                <div style="border: 1px outset white; padding: 2px;">
                                    <div><asp:linkbutton id="lnkReport" runat="server" commandname="Report" text="View Reports"></asp:linkbutton></div>
                                    <div><asp:linkbutton id="lnkDelete" runat="server" commandname="Delete" text="Delete"></asp:linkbutton></div>
                                    <asp:confirmbuttonextender id="cbeNewDelete" runat="server" targetcontrolid="lnkDelete" confirmtext="Are you sure you want to remove this URL?"></asp:confirmbuttonextender>
                                </div>
                            </asp:panel>
                            <asp:hovermenuextender id="hoverMenu" runat="server" popupcontrolid="pnlPopupMenu" popupposition="Right" hovercssclass="popupHover" targetcontrolid="pnlPopupMenu" popdelay="50"></asp:hovermenuextender>
                        </itemtemplate>
                    </asp:templatecolumn>
                </asp:boundcolumn>
            </columns>
</asp:datagrid>

In the ItemDataBound event I am setting the ID to allow it to work for the whole row, I'm using the following for that:

protected void dgrExisting_ItemDataBound(object sender, DataGridItemEventArgs e)
{
    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
        AjaxControlToolkit.HoverMenuExtender oHoverMenu = (AjaxControlToolkit.HoverMenuExtender)e.Item.FindControl("hoverMenu");
        e.Item.ID = e.Item.ItemIndex.ToString();
        oHoverMenu.TargetControlID = e.Item.ID;
    }
}

As it is, the menu displays, however, clicking on the link buttons never actually posts back to the server allowing the item command to be processed. If I disable the hover menu extender, the buttons do work as expected.

What am I missing?

A: 

Instead of trying to implement the behavior in the code behind, I inlined the links...

<itemtemplate>
 <asp:label id="lblOptions" runat="server">Options</asp:label><img src="../Images/RightArrow.png" alt="Show Menu" />

 <asp:panel id="pnlMenu" runat="server" cssclass="popupMenu">
  <div class="popupItem"><a href="Uploader.aspx?Action=Copy&Id=<%#Eval("Id")%>">Copy</a></div>
  <div class="popupItem"><a href="Uploader.aspx?Action=Version&Id=<%#Eval("VersionId")%>">Upload New Version</a></div>
  <div class="popupItem"><a href="VersionBrowser.aspx?id=<%#Eval("Id")%>">View Versions</a></div>
 </asp:panel>

 <cc1:hovermenuextender id="hme" runat="server"
   hovercssclass="popupHover"
   popupcontrolid="pnlMenu"
   targetcontrolid="lblOptions"/>
</itemtemplate>

TGnat
I might have to give this way a try. I was trying to avoid having a column that was visible at all, but if not, this works.
Mitchel Sellers