【问题标题】:Dynamic Data GridView Pager missing DynamicHyperlink Edit parameters动态数据 GridView Pager 缺少 DynamicHyperlink 编辑参数
【发布时间】:2012-02-14 04:24:40
【问题描述】:

编辑:2012 年 2 月 7 日 - 结果在排序后关键参数也从 GridView 编辑链接中消失了,所以它毕竟不是寻呼机,但问题仍然存在......任何想法都非常欢迎。

我有一个 Asp.Net 动态数据应用程序。它使用自定义 List.aspx 中的标准 GridViewPager.aspx,其标记如下:

<asp:GridView ID="GridView1" runat="server" DataSourceID="GridDataSource" EnablePersistedSelection="True" CssClass="DDGridView" HeaderStyle-CssClass="th" RowStyle-CssClass="td" CellPadding="6" AllowSorting="True" AllowPaging="True" PageSize="3"
    OnRowDataBound="GridView_OnRowDataBound" OnRowDeleting="GridView_OnRowDeleting">
    <Columns>
        <asp:TemplateField>
            <ItemTemplate>
                <asp:LoginView ID="LoginView1" runat="server">
                    <RoleGroups>
                        <asp:RoleGroup Roles="admin">
                            <ContentTemplate>
                                <asp:DynamicHyperLink ID="EditLink" runat="server" Action="Edit" Text="edit" />
                                &nbsp;
                                <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Delete" Text="delete" OnClientClick='return confirm("Are you sure you want to delete this item?");' />
                            </ContentTemplate>
                        </asp:RoleGroup>
                    </RoleGroups>
                </asp:LoginView>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
    <PagerStyle CssClass="DDFooter" />
    <PagerTemplate>
        <asp:GridViewPager runat="server" />
    </PagerTemplate>
    <EmptyDataTemplate>
        There are currently no items in this table.
    </EmptyDataTemplate>
</asp:GridView>

在列表的第 1 页上一切正常。呈现的编辑链接包括?key=xxxxx,并且编辑表单打开到正确的记录。

然而,一旦我们离开第 1 页,每行呈现的编辑链接就没有“键”参数,并且编辑表单总是打开到数据库中的第一行。

我无法解释这一点,甚至无法解释。与 Edit DynamicHyperlink 或 GridviewPager 关联的任何事件都没有附加自定义代码。

有没有人遇到过这种情况或对可能出现的问题有任何建议?

【问题讨论】:

    标签: asp.net .net gridview dynamic-data


    【解决方案1】:

    在这里找到答案:

    LinkButton CommandArgument is empty when it is inside LoginView in a GridView

    结果很好,微软忘记连接 LoginView 来触发 GridView 内的行级数据绑定事件。没有数据绑定,没有链接参数!

    为了尊重积极的态度,我不会对允许这种态度的组织水平发表评论......

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-18
      • 1970-01-01
      相关资源
      最近更新 更多