Ajax 控件工具包 Hover Menu with GridView

发布于 2024-12-11 07:41:44 字数 2763 浏览 0 评论 0原文

您好,我正在尝试实现示例悬停菜单的相同功能 http: //www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/HoverMenu/HoverMenu.aspx

但是,当我的 gridview 显示时我将鼠标悬停在菜单上,但仅针对整个 gridview,而不是像示例中那样的每一行?。目前菜单按钮没有任何作用。

    <asp:UpdatePanel ID="up1" runat="server">
        <ContentTemplate>

            <asp:GridView ID="GridView1" runat="server"
                AutoGenerateColumns="False" DataSourceID="BookingsSQL"
                ShowHeader="False" Width="100%" BackColor="Azure" GridLines="None" >
                <Columns>
                    <asp:BoundField DataField="programme_name" HeaderText="programme_name" 
                        SortExpression="programme_name" />
                    <asp:BoundField DataField="Start" HeaderText="Start" SortExpression="Start" />
                    <asp:BoundField DataField="Finish" HeaderText="Finish" 
                        SortExpression="Finish" />
                    <asp:BoundField DataField="Source" HeaderText="Source" 
                        SortExpression="Source" />
                    <asp:BoundField DataField="Destination" HeaderText="Destination" 
                        SortExpression="Destination" />
                    <asp:BoundField DataField="Comment" HeaderText="Comment" 
                        SortExpression="Comment" />
                </Columns>
            </asp:GridView>
            <asp:SqlDataSource ID="BookingsSQL" runat="server"
                ConnectionString="<%$ ConnectionStrings:BookingsConnectionString %>" 
                SelectCommand="SELECT [programme name] AS programme_name, [Start], [Finish], [Source], [Destination], [Comment] FROM [Bookings]">

            </asp:SqlDataSource>

            <asp:HoverMenuExtender ID="HoverMenuExtender1" runat="server"
             TargetControlID="GridView1"
                PopupControlID="PopupMenu"
                HoverCssClass="popupHover"
                PopupPosition="Left"
                OffsetX="0"
                OffsetY="0"
                PopDelay="50">
            </asp:HoverMenuExtender>
           <asp:Panel CssClass="popupMenu" ID="PopupMenu"  runat="server">
                <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Edit" Text="Edit" />
                <br />
                <asp:LinkButton ID="LinkButton2" runat="server" 
                 CommandName="Delete" Text="Delete" />
            </asp:Panel>

        </ContentTemplate>

    </asp:UpdatePanel>

使用jquery悬停尝试了几种不同的方法,但这将是最好的解决方案。 请提供任何帮助。谢谢。

Hi there I am trying to achieve the same functionality of the Example Hover menu over at http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/HoverMenu/HoverMenu.aspx

However when my gridview display's and I mouse over the menu comes up but only for the entire gridview not each row like in the example ?. currently the menu buttons do nothing.

    <asp:UpdatePanel ID="up1" runat="server">
        <ContentTemplate>

            <asp:GridView ID="GridView1" runat="server"
                AutoGenerateColumns="False" DataSourceID="BookingsSQL"
                ShowHeader="False" Width="100%" BackColor="Azure" GridLines="None" >
                <Columns>
                    <asp:BoundField DataField="programme_name" HeaderText="programme_name" 
                        SortExpression="programme_name" />
                    <asp:BoundField DataField="Start" HeaderText="Start" SortExpression="Start" />
                    <asp:BoundField DataField="Finish" HeaderText="Finish" 
                        SortExpression="Finish" />
                    <asp:BoundField DataField="Source" HeaderText="Source" 
                        SortExpression="Source" />
                    <asp:BoundField DataField="Destination" HeaderText="Destination" 
                        SortExpression="Destination" />
                    <asp:BoundField DataField="Comment" HeaderText="Comment" 
                        SortExpression="Comment" />
                </Columns>
            </asp:GridView>
            <asp:SqlDataSource ID="BookingsSQL" runat="server"
                ConnectionString="<%$ ConnectionStrings:BookingsConnectionString %>" 
                SelectCommand="SELECT [programme name] AS programme_name, [Start], [Finish], [Source], [Destination], [Comment] FROM [Bookings]">

            </asp:SqlDataSource>

            <asp:HoverMenuExtender ID="HoverMenuExtender1" runat="server"
             TargetControlID="GridView1"
                PopupControlID="PopupMenu"
                HoverCssClass="popupHover"
                PopupPosition="Left"
                OffsetX="0"
                OffsetY="0"
                PopDelay="50">
            </asp:HoverMenuExtender>
           <asp:Panel CssClass="popupMenu" ID="PopupMenu"  runat="server">
                <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Edit" Text="Edit" />
                <br />
                <asp:LinkButton ID="LinkButton2" runat="server" 
                 CommandName="Delete" Text="Delete" />
            </asp:Panel>

        </ContentTemplate>

    </asp:UpdatePanel>

Tried a few different ways using jquery hover but this would be the best solution.
Any help please . Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

源来凯始玺欢你 2024-12-18 07:41:44

有解决办法。
为每一行实现 HoverExtender 并不那么棘手,因为这在示例工具包示例中显示,为提供带有排序的列标题。

请注意,预订表中添加了代理主键,以允许编辑所有字段值。此外,还使用 ​​jQuery datepicker 插件来编辑“开始”和“完成”字段值。您可以使用 AjaxControlToolkit 中的 DatePickerExtender,但在这种情况下,必须为网格中的每一行单独添加这些扩展程序以及 HoverExtender。

<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataSourceID="BookingsSQL"
     ShowHeader="False" Width="100%" BackColor="Azure" GridLines="None" DataKeyNames="ID">
     <Columns>
          <asp:TemplateField>
               <ItemTemplate>
                    <table runat="server" visible="<%# Container.DataItemIndex == 0 %>">
                         <tr>
                              <th width="20%">
                                   <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="programme_name">
                                        Programme Name
                                   </asp:LinkButton>
                              </th>
                              <th width="20%">
                                   <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Start">
                                        Start
                                   </asp:LinkButton>
                              </th>
                              <th width="20%">
                                   <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Finish">
                                        Finish
                                   </asp:LinkButton>
                              </th>
                              <th width="20%">
                                   <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Source">
                                        Source
                                   </asp:LinkButton>
                              </th>
                              <th width="20%">
                                   <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Destination">
                                        Destination
                                   </asp:LinkButton>
                              </th>
                              <th width="20%">
                                   <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Comment">
                                        Comment
                                   </asp:LinkButton>
                              </th>
                         </tr>
                    </table>
                    <asp:Panel runat="server" ID="ItemContainer">
                         <table width="100%">
                              <tr>
                                   <td width="20%">
                                        <%# Eval("programme_name") %>
                                   </td>
                                   <td width="20%">
                                        <%# Eval("Start", "{0:dd/MM/yyyy}") %>
                                   </td>
                                   <td width="20%">
                                        <%# Eval("Finish", "{0:dd/MM/yyyy}") %>
                                   </td>
                                   <td width="20%">
                                        <%# Eval("Source") %>
                                   </td>
                                   <td width="20%">
                                        <%# Eval("Destination") %>
                                   </td>
                                   <td width="20%">
                                        <%# Eval("Comment") %>
                                   </td>
                              </tr>
                         </table>
                    </asp:Panel>
                    <asp:Panel CssClass="popupMenu" ID="PopupMenu" runat="server">
                         <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Edit" Text="Edit" />
                         <br />
                         <asp:LinkButton ID="LinkButton2" runat="server" CommandName="Delete" Text="Delete" />
                    </asp:Panel>
                    <ajaxToolkit:HoverMenuExtender runat="server" TargetControlID="ItemContainer" PopupControlID="popupMenu"
                         HoverCssClass="popupHover" PopupPosition="Left" OffsetX="0" OffsetY="0" PopDelay="50">
                    </ajaxToolkit:HoverMenuExtender>
               </ItemTemplate>
               <EditItemTemplate>
                    <table id="Table1" runat="server" visible="<%# Container.DataItemIndex == 0 %>">
                         <tr>
                              <th width="20%">
                                   <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="programme_name">
                                        Programme Name
                                   </asp:LinkButton>
                              </th>
                              <th width="20%">
                                   <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Start">
                                        Start
                                   </asp:LinkButton>
                              </th>
                              <th width="20%">
                                   <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Finish">
                                        Finish
                                   </asp:LinkButton>
                              </th>
                              <th width="20%">
                                   <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Source">
                                        Source
                                   </asp:LinkButton>
                              </th>
                              <th width="20%">
                                   <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Destination">
                                        Destination
                                   </asp:LinkButton>
                              </th>
                              <th width="20%">
                                   <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Comment">
                                        Comment
                                   </asp:LinkButton>
                              </th>
                         </tr>
                    </table>
                    <asp:Panel runat="server" ID="ItemContainer">
                         <asp:HiddenField runat="server" ID="IdHiddenField" Value='<%# Bind("ID") %>' />
                         <table width="100%">
                              <tr>
                                   <td width="20%">
                                        <asp:TextBox ID="TextBox0" runat="server" Text='<%# Bind("programme_name") %>' />
                                   </td>
                                   <td width="20%">
                                        <asp:TextBox ID="TextBox2" CssClass="datePicker" runat="server" Text='<%# Bind("Start", "{0:dd/MM/yyyy}") %>' />
                                   </td>
                                   <td width="20%">
                                        <asp:TextBox ID="TextBox3" CssClass="datePicker" runat="server" Text='<%# Bind("Finish", "{0:dd/MM/yyyy}") %>' />
                                   </td>
                                   <td width="20%">
                                        <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Source") %>' />
                                   </td>
                                   <td width="20%">
                                        <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("Destination") %>' />
                                   </td>
                                   <td width="20%">
                                        <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("Comment") %>' />
                                   </td>
                              </tr>
                         </table>
                    </asp:Panel>
                    <asp:Panel CssClass="popupMenu" ID="PopupMenu" runat="server">
                         <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Update" CausesValidation="true"
                              Text="Update" />
                         <br />
                         <asp:LinkButton ID="LinkButton2" runat="server" CommandName="Cancel" CausesValidation="false"
                              Text="Cancel" />
                    </asp:Panel>
                    <ajaxToolkit:HoverMenuExtender runat="server" TargetControlID="ItemContainer" PopupControlID="popupMenu"
                         HoverCssClass="popupHover" PopupPosition="Left" OffsetX="0" OffsetY="0" PopDelay="50">
                    </ajaxToolkit:HoverMenuExtender>
               </EditItemTemplate>
          </asp:TemplateField>
     </Columns>
</asp:GridView>
<asp:SqlDataSource ID="BookingsSQL" runat="server" ConnectionString="<%$ ConnectionStrings:BookingsConnectionString %>"
     OldValuesParameterFormatString="original_{0}" ConflictDetection="OverwriteChanges"
     SelectCommand="SELECT [ID], [programme name] AS programme_name, [Start], [Finish], [Source], [Destination], [Comment] FROM [Bookings]"
     DeleteCommand="DELETE FROM [Bookings] WHERE [programme name] = @ID" InsertCommand="INSERT INTO [Bookings] ([programme name], [Start], [Finish], [Source], [Destination], [Comment]) VALUES (@programme_name, @Start, @Finish, @Source, @Destination, @Comment)"
     UpdateCommand="UPDATE [Bookings] SET [programme name] = @programme_name, [Start] = @Start, [Finish] = @Finish, [Source] = @Source, [Destination] = @Destination, [Comment] = @Comment WHERE [ID] = @ID">
     <DeleteParameters>
          <asp:Parameter Name="ID" Type="Int32" />
     </DeleteParameters>
     <InsertParameters>
          <asp:Parameter Name="programme_name" Type="String" />
          <asp:Parameter Name="Start" Type="DateTime" />
          <asp:Parameter Name="Finish" Type="DateTime" />
          <asp:Parameter Name="Source" Type="String" />
          <asp:Parameter Name="Destination" Type="String" />
          <asp:Parameter Name="Comment" Type="String" />
     </InsertParameters>
     <UpdateParameters>
          <asp:Parameter Name="ID" Type="Int32" />
          <asp:Parameter Name="Start" Type="DateTime" />
          <asp:Parameter Name="Finish" Type="DateTime" />
          <asp:Parameter Name="Source" Type="String" />
          <asp:Parameter Name="Destination" Type="String" />
          <asp:Parameter Name="Comment" Type="String" />
          <asp:Parameter Name="programme_name" Type="String" />
     </UpdateParameters>
</asp:SqlDataSource>

There is solution.
It's not so tricky to implement a HoverExtender for each row since this showed in sample toolkit sample, as to provide columns headers with sorting.

Draw attention that there is surrogate primary key added to Bookings table for allowing editing all fields values. Also there is used jQuery datepicker plugin for editing Start and Finish fields values. You may use DatePickerExtender from the AjaxControlToolkit instead, but in that case those extenders as well as the HoverExtenders must be added for each row in grid separately.

<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataSourceID="BookingsSQL"
     ShowHeader="False" Width="100%" BackColor="Azure" GridLines="None" DataKeyNames="ID">
     <Columns>
          <asp:TemplateField>
               <ItemTemplate>
                    <table runat="server" visible="<%# Container.DataItemIndex == 0 %>">
                         <tr>
                              <th width="20%">
                                   <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="programme_name">
                                        Programme Name
                                   </asp:LinkButton>
                              </th>
                              <th width="20%">
                                   <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Start">
                                        Start
                                   </asp:LinkButton>
                              </th>
                              <th width="20%">
                                   <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Finish">
                                        Finish
                                   </asp:LinkButton>
                              </th>
                              <th width="20%">
                                   <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Source">
                                        Source
                                   </asp:LinkButton>
                              </th>
                              <th width="20%">
                                   <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Destination">
                                        Destination
                                   </asp:LinkButton>
                              </th>
                              <th width="20%">
                                   <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Comment">
                                        Comment
                                   </asp:LinkButton>
                              </th>
                         </tr>
                    </table>
                    <asp:Panel runat="server" ID="ItemContainer">
                         <table width="100%">
                              <tr>
                                   <td width="20%">
                                        <%# Eval("programme_name") %>
                                   </td>
                                   <td width="20%">
                                        <%# Eval("Start", "{0:dd/MM/yyyy}") %>
                                   </td>
                                   <td width="20%">
                                        <%# Eval("Finish", "{0:dd/MM/yyyy}") %>
                                   </td>
                                   <td width="20%">
                                        <%# Eval("Source") %>
                                   </td>
                                   <td width="20%">
                                        <%# Eval("Destination") %>
                                   </td>
                                   <td width="20%">
                                        <%# Eval("Comment") %>
                                   </td>
                              </tr>
                         </table>
                    </asp:Panel>
                    <asp:Panel CssClass="popupMenu" ID="PopupMenu" runat="server">
                         <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Edit" Text="Edit" />
                         <br />
                         <asp:LinkButton ID="LinkButton2" runat="server" CommandName="Delete" Text="Delete" />
                    </asp:Panel>
                    <ajaxToolkit:HoverMenuExtender runat="server" TargetControlID="ItemContainer" PopupControlID="popupMenu"
                         HoverCssClass="popupHover" PopupPosition="Left" OffsetX="0" OffsetY="0" PopDelay="50">
                    </ajaxToolkit:HoverMenuExtender>
               </ItemTemplate>
               <EditItemTemplate>
                    <table id="Table1" runat="server" visible="<%# Container.DataItemIndex == 0 %>">
                         <tr>
                              <th width="20%">
                                   <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="programme_name">
                                        Programme Name
                                   </asp:LinkButton>
                              </th>
                              <th width="20%">
                                   <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Start">
                                        Start
                                   </asp:LinkButton>
                              </th>
                              <th width="20%">
                                   <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Finish">
                                        Finish
                                   </asp:LinkButton>
                              </th>
                              <th width="20%">
                                   <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Source">
                                        Source
                                   </asp:LinkButton>
                              </th>
                              <th width="20%">
                                   <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Destination">
                                        Destination
                                   </asp:LinkButton>
                              </th>
                              <th width="20%">
                                   <asp:LinkButton runat="server" CommandName="Sort" CommandArgument="Comment">
                                        Comment
                                   </asp:LinkButton>
                              </th>
                         </tr>
                    </table>
                    <asp:Panel runat="server" ID="ItemContainer">
                         <asp:HiddenField runat="server" ID="IdHiddenField" Value='<%# Bind("ID") %>' />
                         <table width="100%">
                              <tr>
                                   <td width="20%">
                                        <asp:TextBox ID="TextBox0" runat="server" Text='<%# Bind("programme_name") %>' />
                                   </td>
                                   <td width="20%">
                                        <asp:TextBox ID="TextBox2" CssClass="datePicker" runat="server" Text='<%# Bind("Start", "{0:dd/MM/yyyy}") %>' />
                                   </td>
                                   <td width="20%">
                                        <asp:TextBox ID="TextBox3" CssClass="datePicker" runat="server" Text='<%# Bind("Finish", "{0:dd/MM/yyyy}") %>' />
                                   </td>
                                   <td width="20%">
                                        <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Source") %>' />
                                   </td>
                                   <td width="20%">
                                        <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("Destination") %>' />
                                   </td>
                                   <td width="20%">
                                        <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("Comment") %>' />
                                   </td>
                              </tr>
                         </table>
                    </asp:Panel>
                    <asp:Panel CssClass="popupMenu" ID="PopupMenu" runat="server">
                         <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Update" CausesValidation="true"
                              Text="Update" />
                         <br />
                         <asp:LinkButton ID="LinkButton2" runat="server" CommandName="Cancel" CausesValidation="false"
                              Text="Cancel" />
                    </asp:Panel>
                    <ajaxToolkit:HoverMenuExtender runat="server" TargetControlID="ItemContainer" PopupControlID="popupMenu"
                         HoverCssClass="popupHover" PopupPosition="Left" OffsetX="0" OffsetY="0" PopDelay="50">
                    </ajaxToolkit:HoverMenuExtender>
               </EditItemTemplate>
          </asp:TemplateField>
     </Columns>
</asp:GridView>
<asp:SqlDataSource ID="BookingsSQL" runat="server" ConnectionString="<%$ ConnectionStrings:BookingsConnectionString %>"
     OldValuesParameterFormatString="original_{0}" ConflictDetection="OverwriteChanges"
     SelectCommand="SELECT [ID], [programme name] AS programme_name, [Start], [Finish], [Source], [Destination], [Comment] FROM [Bookings]"
     DeleteCommand="DELETE FROM [Bookings] WHERE [programme name] = @ID" InsertCommand="INSERT INTO [Bookings] ([programme name], [Start], [Finish], [Source], [Destination], [Comment]) VALUES (@programme_name, @Start, @Finish, @Source, @Destination, @Comment)"
     UpdateCommand="UPDATE [Bookings] SET [programme name] = @programme_name, [Start] = @Start, [Finish] = @Finish, [Source] = @Source, [Destination] = @Destination, [Comment] = @Comment WHERE [ID] = @ID">
     <DeleteParameters>
          <asp:Parameter Name="ID" Type="Int32" />
     </DeleteParameters>
     <InsertParameters>
          <asp:Parameter Name="programme_name" Type="String" />
          <asp:Parameter Name="Start" Type="DateTime" />
          <asp:Parameter Name="Finish" Type="DateTime" />
          <asp:Parameter Name="Source" Type="String" />
          <asp:Parameter Name="Destination" Type="String" />
          <asp:Parameter Name="Comment" Type="String" />
     </InsertParameters>
     <UpdateParameters>
          <asp:Parameter Name="ID" Type="Int32" />
          <asp:Parameter Name="Start" Type="DateTime" />
          <asp:Parameter Name="Finish" Type="DateTime" />
          <asp:Parameter Name="Source" Type="String" />
          <asp:Parameter Name="Destination" Type="String" />
          <asp:Parameter Name="Comment" Type="String" />
          <asp:Parameter Name="programme_name" Type="String" />
     </UpdateParameters>
</asp:SqlDataSource>
甜中书 2024-12-18 07:41:44

感谢您提供如此大的帮助...它对我有用,我使用 SqlDataSource 而不是使用 objectDataSource...
这是我正在运行的代码,对我来说非常有用......

<asp:UpdatePanel ID="up1" runat="server">
    <ContentTemplate>

<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
 ShowHeader="False" Width="100%" BackColor="Azure" GridLines="None" DataKeyNames="PageAddID">
 <Columns>
      <asp:TemplateField>
           <ItemTemplate>
                <table id="Table1" runat="server" visible="<%# Container.DataItemIndex == 0 %>">
                     <tr>
                          <th width="20%">
                               <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Sort" CommandArgument="PageName">
                                    Page Name
                               </asp:LinkButton>
                          </th>
                          <th width="20%">
                               <asp:LinkButton ID="LinkButton2" runat="server" CommandName="Sort" CommandArgument="PageTitle">
                                    PageTitle
                               </asp:LinkButton>
                          </th>
                          <th width="20%">
                               <asp:LinkButton ID="LinkButton3" runat="server" CommandName="Sort" CommandArgument="Metakeyword">
                                    Metakeyword
                               </asp:LinkButton>
                          </th>
                          <th width="20%">
                               <asp:LinkButton ID="LinkButton4" runat="server" CommandName="Sort" CommandArgument="Description">
                                    Description
                               </asp:LinkButton>
                          </th>

                     </tr>
                </table>
                <asp:Panel runat="server" ID="ItemContainer">
                     <table width="100%">
                          <tr>
                               <td width="20%">
                                    <%# Eval("PageName") %>
                               </td>
                               <td width="20%">
                                    <%# Eval("PageTitle") %>
                               </td>
                               <td width="20%">
                                    <%# Eval("Metakeyword") %>
                               </td>
                               <td width="20%">
                                    <%# Eval("Description") %>
                               </td>

                          </tr>
                     </table>
                </asp:Panel>
                <asp:Panel CssClass="popupMenu" ID="PopupMenu" runat="server">
                     <asp:LinkButton ID="LinkButton5" runat="server" CommandName="Edit" Text="Edit" />
                     <br />
                     <asp:LinkButton ID="LinkButton6" runat="server" CommandName="Delete" Text="Delete" />
                </asp:Panel>
                <ajaxToolkit:HoverMenuExtender ID="HoverMenuExtender1" runat="server" TargetControlID="ItemContainer" PopupControlID="popupMenu"
                     HoverCssClass="popupHover" PopupPosition="Left" OffsetX="0" OffsetY="0" PopDelay="10">
                </ajaxToolkit:HoverMenuExtender>
           </ItemTemplate>
           <EditItemTemplate>
                <table id="Table1" runat="server" visible="<%# Container.DataItemIndex == 0 %>">
                       <tr>
                          <th width="20%">
                               <asp:LinkButton ID="LinkButton7" runat="server" CommandName="Sort" CommandArgument="PageName">
                                    Page Name
                               </asp:LinkButton>
                          </th>
                          <th width="20%">
                               <asp:LinkButton ID="LinkButton8" runat="server" CommandName="Sort" CommandArgument="PageTitle">
                                    PageTitle
                               </asp:LinkButton>
                          </th>
                          <th width="20%">
                               <asp:LinkButton ID="LinkButton9" runat="server" CommandName="Sort" CommandArgument="Metakeyword">
                                    Metakeyword
                               </asp:LinkButton>
                          </th>
                          <th width="20%">
                               <asp:LinkButton ID="LinkButton10" runat="server" CommandName="Sort" CommandArgument="Description">
                                    Description
                               </asp:LinkButton>
                          </th>

                     </tr>
                </table>
                <asp:Panel runat="server" ID="ItemContainer">
                     <asp:HiddenField runat="server" ID="IdHiddenField" Value='<%# Bind("PageAddID") %>' />
                     <table width="100%">
                          <tr>
                               <td width="20%">
                                    <asp:TextBox ID="TextBox0" runat="server" Text='<%# Bind("PageName") %>' />
                               </td>
                               <td width="20%">
                                    <asp:TextBox ID="TextBox2" CssClass="datePicker" runat="server" Text='<%# Bind("PageTitle") %>' />
                               </td>
                               <td width="20%">
                                    <asp:TextBox ID="TextBox3" CssClass="datePicker" runat="server" Text='<%# Bind("Metakeyword") %>' />
                               </td>
                               <td width="20%">
                                    <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Description") %>' />
                               </td>

                          </tr>
                     </table>
                </asp:Panel>
                <asp:Panel CssClass="popupMenu" ID="PopupMenu" runat="server">
                     <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Update" CausesValidation="true"
                          Text="Update" />
                     <br />
                     <asp:LinkButton ID="LinkButton2" runat="server" CommandName="Cancel" CausesValidation="false"
                          Text="Cancel" />
                </asp:Panel>
                <ajaxToolkit:HoverMenuExtender ID="HoverMenuExtender2" runat="server" TargetControlID="ItemContainer" PopupControlID="popupMenu"
                     HoverCssClass="popupHover" PopupPosition="Left" OffsetX="0" OffsetY="0" PopDelay="10">
                </ajaxToolkit:HoverMenuExtender>
           </EditItemTemplate>
      </asp:TemplateField>
 </Columns>


OldValuesParameterFormatString="original_{0}" ConflictDetection="OverwriteChanges"
SelectCommand="从 [AddPages] 选择 *"
DeleteCommand="从 [AddPages] 删除,其中 [PageAddId] = @PageAddID"

 UpdateCommand="UPDATE [AddPages] SET [PageName] = @PageName, [PageTitle] = @PageTitle, [Metakeyword] = @Metakeyword, [Description] = @Description WHERE [PageAddID] = @PageAddID">
 <DeleteParameters>
      <asp:Parameter Name="PageAddID" Type="Int32" />
 </DeleteParameters>
 <InsertParameters>
      <asp:Parameter Name="PageName" Type="string" />
      <asp:Parameter Name="PageTitle" Type="string" />
      <asp:Parameter Name="Metakeyword" Type="string" />
      <asp:Parameter Name="Description" Type="string" />

 </InsertParameters>
 <UpdateParameters>
      <asp:Parameter Name="PageAddID" Type="Int32" />
        <asp:Parameter Name="PageName" Type="string" />
      <asp:Parameter Name="PageTitle" Type="string" />
      <asp:Parameter Name="Metakeyword" Type="string" />
      <asp:Parameter Name="Description" Type="string" />

 </UpdateParameters>

    </ContentTemplate>
</asp:UpdatePanel>

Thanks for such a great help... its working for me i have used SqlDataSource instead of using objectDataSource...
here is my running code that is working great for me....

<asp:UpdatePanel ID="up1" runat="server">
    <ContentTemplate>

<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
 ShowHeader="False" Width="100%" BackColor="Azure" GridLines="None" DataKeyNames="PageAddID">
 <Columns>
      <asp:TemplateField>
           <ItemTemplate>
                <table id="Table1" runat="server" visible="<%# Container.DataItemIndex == 0 %>">
                     <tr>
                          <th width="20%">
                               <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Sort" CommandArgument="PageName">
                                    Page Name
                               </asp:LinkButton>
                          </th>
                          <th width="20%">
                               <asp:LinkButton ID="LinkButton2" runat="server" CommandName="Sort" CommandArgument="PageTitle">
                                    PageTitle
                               </asp:LinkButton>
                          </th>
                          <th width="20%">
                               <asp:LinkButton ID="LinkButton3" runat="server" CommandName="Sort" CommandArgument="Metakeyword">
                                    Metakeyword
                               </asp:LinkButton>
                          </th>
                          <th width="20%">
                               <asp:LinkButton ID="LinkButton4" runat="server" CommandName="Sort" CommandArgument="Description">
                                    Description
                               </asp:LinkButton>
                          </th>

                     </tr>
                </table>
                <asp:Panel runat="server" ID="ItemContainer">
                     <table width="100%">
                          <tr>
                               <td width="20%">
                                    <%# Eval("PageName") %>
                               </td>
                               <td width="20%">
                                    <%# Eval("PageTitle") %>
                               </td>
                               <td width="20%">
                                    <%# Eval("Metakeyword") %>
                               </td>
                               <td width="20%">
                                    <%# Eval("Description") %>
                               </td>

                          </tr>
                     </table>
                </asp:Panel>
                <asp:Panel CssClass="popupMenu" ID="PopupMenu" runat="server">
                     <asp:LinkButton ID="LinkButton5" runat="server" CommandName="Edit" Text="Edit" />
                     <br />
                     <asp:LinkButton ID="LinkButton6" runat="server" CommandName="Delete" Text="Delete" />
                </asp:Panel>
                <ajaxToolkit:HoverMenuExtender ID="HoverMenuExtender1" runat="server" TargetControlID="ItemContainer" PopupControlID="popupMenu"
                     HoverCssClass="popupHover" PopupPosition="Left" OffsetX="0" OffsetY="0" PopDelay="10">
                </ajaxToolkit:HoverMenuExtender>
           </ItemTemplate>
           <EditItemTemplate>
                <table id="Table1" runat="server" visible="<%# Container.DataItemIndex == 0 %>">
                       <tr>
                          <th width="20%">
                               <asp:LinkButton ID="LinkButton7" runat="server" CommandName="Sort" CommandArgument="PageName">
                                    Page Name
                               </asp:LinkButton>
                          </th>
                          <th width="20%">
                               <asp:LinkButton ID="LinkButton8" runat="server" CommandName="Sort" CommandArgument="PageTitle">
                                    PageTitle
                               </asp:LinkButton>
                          </th>
                          <th width="20%">
                               <asp:LinkButton ID="LinkButton9" runat="server" CommandName="Sort" CommandArgument="Metakeyword">
                                    Metakeyword
                               </asp:LinkButton>
                          </th>
                          <th width="20%">
                               <asp:LinkButton ID="LinkButton10" runat="server" CommandName="Sort" CommandArgument="Description">
                                    Description
                               </asp:LinkButton>
                          </th>

                     </tr>
                </table>
                <asp:Panel runat="server" ID="ItemContainer">
                     <asp:HiddenField runat="server" ID="IdHiddenField" Value='<%# Bind("PageAddID") %>' />
                     <table width="100%">
                          <tr>
                               <td width="20%">
                                    <asp:TextBox ID="TextBox0" runat="server" Text='<%# Bind("PageName") %>' />
                               </td>
                               <td width="20%">
                                    <asp:TextBox ID="TextBox2" CssClass="datePicker" runat="server" Text='<%# Bind("PageTitle") %>' />
                               </td>
                               <td width="20%">
                                    <asp:TextBox ID="TextBox3" CssClass="datePicker" runat="server" Text='<%# Bind("Metakeyword") %>' />
                               </td>
                               <td width="20%">
                                    <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Description") %>' />
                               </td>

                          </tr>
                     </table>
                </asp:Panel>
                <asp:Panel CssClass="popupMenu" ID="PopupMenu" runat="server">
                     <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Update" CausesValidation="true"
                          Text="Update" />
                     <br />
                     <asp:LinkButton ID="LinkButton2" runat="server" CommandName="Cancel" CausesValidation="false"
                          Text="Cancel" />
                </asp:Panel>
                <ajaxToolkit:HoverMenuExtender ID="HoverMenuExtender2" runat="server" TargetControlID="ItemContainer" PopupControlID="popupMenu"
                     HoverCssClass="popupHover" PopupPosition="Left" OffsetX="0" OffsetY="0" PopDelay="10">
                </ajaxToolkit:HoverMenuExtender>
           </EditItemTemplate>
      </asp:TemplateField>
 </Columns>

"
OldValuesParameterFormatString="original_{0}" ConflictDetection="OverwriteChanges"
SelectCommand="SELECT * FROM [AddPages]"
DeleteCommand="DELETE FROM [AddPages] WHERE [PageAddId] = @PageAddID"

 UpdateCommand="UPDATE [AddPages] SET [PageName] = @PageName, [PageTitle] = @PageTitle, [Metakeyword] = @Metakeyword, [Description] = @Description WHERE [PageAddID] = @PageAddID">
 <DeleteParameters>
      <asp:Parameter Name="PageAddID" Type="Int32" />
 </DeleteParameters>
 <InsertParameters>
      <asp:Parameter Name="PageName" Type="string" />
      <asp:Parameter Name="PageTitle" Type="string" />
      <asp:Parameter Name="Metakeyword" Type="string" />
      <asp:Parameter Name="Description" Type="string" />

 </InsertParameters>
 <UpdateParameters>
      <asp:Parameter Name="PageAddID" Type="Int32" />
        <asp:Parameter Name="PageName" Type="string" />
      <asp:Parameter Name="PageTitle" Type="string" />
      <asp:Parameter Name="Metakeyword" Type="string" />
      <asp:Parameter Name="Description" Type="string" />

 </UpdateParameters>

    </ContentTemplate>
</asp:UpdatePanel>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文