gpt4 book ai didi

asp.net - Ajax 控件工具包 Hover Menu with GridView

转载 作者:行者123 更新时间:2023-12-02 16:45:45 31 4
gpt4 key购买 nike

您好,我正在尝试实现与 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悬停尝试了几种不同的方法,但这将是最好的解决方案。请提供任何帮助。谢谢。

最佳答案

有解决办法。为每一行实现 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>

关于asp.net - Ajax 控件工具包 Hover Menu with GridView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7847663/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com