views:

220

answers:

0

I have SPGridView that has SPMenuField. I placed SPGridview in UpdatePanel. SPMenuField has 2 MenuItemTemplates "Edit" "Delete". When I click on any of the the MenuItem, the whole page is refreshing. I dont want to do that. How can I avoid that? See my code below.

<script type="text/javascript">
function CareerHistoryFunction(param) {
    var myArray = param.split(",");
    if (myArray[0] == "DELETE") {
        if (confirm("Are you sure you want to delete this item?")) {
            //            alert("Woo Hoo! So am I.")
            __doPostBack('<%= this.UniqueID %>', param);
        }
        else {
            window.stop();
        }
    }
    else {
        __doPostBack('<%= this.UniqueID %>', param);
    }
}

        <SharePoint:MenuTemplate runat="server" ID="careerHistoryListMenu" EnableSorting="true"  >
            <SharePoint:MenuItemTemplate ID="Edit" runat="server" Text="Edit" ImageUrl="/_layouts/images/edititem.gif"                 
            ClientOnClickScript="CareerHistoryFunction('EDIT,%ID%');"></SharePoint:MenuItemTemplate>
            <SharePoint:MenuItemTemplate ID="Delete" runat="server" Text="Delete" ImageUrl="\_layouts\images\DELETE.GIF"  
            ClientOnClickScript ="CareerHistoryFunction('DELETE, %ID%');"></SharePoint:MenuItemTemplate>                
        </SharePoint:MenuTemplate>

        <SharePoint:SPGridView ID="grdViewCareerHistory" runat="server" Width="100%" AutoGenerateColumns="false" AllowSorting="true" EnableViewState="true" >
        <EmptyDataTemplate>
                There are no items to show in this view. 
        </EmptyDataTemplate>
        <Columns>

        <SharePoint:SPMenuField HeaderText="careerHistory" TextFields="CareerHistory" 
        MenuTemplateId="CareerHistoryListMenu" SortExpression="CareerHistory" 
        NavigateUrlFields="Id" NavigateUrlFormat="default.aspx?{0}"
        TokenNameAndValueFields="ID=ID" ItemStyle-Width="40%" >
        </SharePoint:SPMenuField>
        <asp:BoundField HeaderText="careerHistory" DataField="careerHistoryTitle" ItemStyle-Width="40%" Visible=false />
        <asp:BoundField HeaderText="From" DataField="From" SortExpression="From" ItemStyle-Width="15%" />
         <asp:BoundField HeaderText="Through" DataField="Through" SortExpression="Through" ItemStyle-Width="5%" />
        <asp:BoundField HeaderText="To" DataField="To" SortExpression="To" ItemStyle-Width="40%" />

        </Columns>
        </SharePoint:SPGridView>
    </asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="blank1" Height="2">
    <asp:TableCell Height="5">
        <img width="1" height="5" alt="" src="/_layouts/images/blank.gif"/>
    </asp:TableCell>
</asp:TableRow>