views:

358

answers:

2

hi experts, I have a asp:GridView and inside it I have some TemplateFileds, one of them used for show a HoverMenu Panel to User

in more details, gridview shows the personal information andwhen user mouseover the row a panel would appear andshows the complete information.

this is the TemplateField

<asp:TemplateField meta:resourcekey="grdListTemplateFieldID">
                    <ItemTemplate>
                        <asp:HoverMenuExtender ID="HoverMenuExtender" runat="server"
                            PopupControlID="PopupMenu" PopupPosition="Center" OffsetY="30" OffsetX="10" PopDelay="50"
                            HoverCssClass="hoverMenu" >        
                        </asp:HoverMenuExtender>
                        <asp:Panel ID="PopupMenu" CssClass="popupMenu" runat="server">
                            <div id="RequestHoverTitle">
                                <asp:Label ID="lblTitle" runat="server" meta:resourcekey="lblTitle" />
                            </div>
                            <div id="NameContainer">
                                <asp:Label ID="lblFullName" runat="server" SkinID="BoldLabel" meta:resourcekey="lblFullName" />
                                <asp:Label ID="lblReqName" runat="server" SkinID="ListLabel" Text='<%# Eval("Name") %>' />
                                <asp:Label ID="lblReqLastName" runat="server" SkinID="ListLabel" Text='<%# Eval("Family") %>' />
                            </div>

. . some other data .

and in code behind I have a method that gives the ID (dataKeyname) to panel for its internal job it is

protected void grdList_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        HoverMenuExtender hoverMenu = e.Row.FindControl("HoverMenuExtender") as HoverMenuExtender;

        if (hoverMenu != null)
        {
            e.Row.Attributes["id"] = e.Row.ClientID;
            hoverMenu.TargetControlID = e.Row.UniqueID;
        }
    }

and finally everything work fine for me

I have 2 problem with this code

first: if user Logout of the page with provided logout link (in master page) will see the

The TargetControlID of 'HoverMenuExtender' is not valid. The value cannot be null or empty.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Source Error: 

and this message will appear whenever I want to Postback the page (if a submit proccess happen , or a fileupload or vice versa

any help appriciated

A: 

Hey,

Try wrapping this code with:

if (e.Row.RowType == DataControlRowType.DataRow)
{
  //assign target id
}
Brian
h BrianI put you code in RoDataBound Event of grdList.Iput allof mycode inside it and also , use tis inside of if(hoverMenu == null) conditionbut nothing work.where am i mistaking ? or please show me another solution
Nasser Hadjloo
OK, this may need some debugging; what I would try is disable that code/extender for the time being. Then run through both scenarios (logged in/out), and look at the GridVIew's markup, and see if the ID's are really null.Also, if the user is logged out, what data gets bound to that grid? Do you bind a null data source? Does that grid display any data when there are no records?
Brian
dear Brian, the loggedout user do not havepermition to see the list content, and when gridview is null ( I mean the datasource is null ) the gridview do not show anything, so nothings showed, but when user is logged in or try to postback (submit) the page broken,
Nasser Hadjloo
If gridview is null, and the data source is null, then why would the hovermenuextender even exist if no rows get rendered? Could there be a different hovermenuextender that is causing the issue? Or, is viewstate reloading and the reloaded extenders don't have the value assigned? Maybe you need to assign the value in the RowCreated event? Also, maybe you need to supply a default targetcontrolID,and switch it to the ID of the server row in RowCreated or RowDataBOund? A few options there...
Brian
A: 

cause I have assigned TargetControlID of HoverMenuExtender in code behind in, so I didn't assign the targetControlID in ASP Markup,

so I set targetControlID of the HoverMenuExtender in Markup to GridView ID and the issue resolved,

for upcomingusers I should say that you can set targetControlID of the HoverMenuExtender to any ID you like, and then cause you set it in the codebehind, it everride your invalid ID with a valid ID.

Nasser Hadjloo