带有对象数据源删除的列表视图不起作用

发布于 2024-08-16 12:01:36 字数 3565 浏览 3 评论 0原文

我的用户控件中有一个列表视图1. 与ListView绑定的objectdatasource。 现在在objectdatasource的Delete方法中,我已将businessobject作为参数,但在运行时我没有在我的businessobject的属性中获得值...

我还尝试在ItemTemplate中使用“Bind”而不是“eval”。但在运行时在objectdatasource的Deletecommand中提供的DeleteMethod中没有获得任何值... 有人能帮忙知道我错过了什么吗?

我的列表视图的 ItemTemplate

 <ItemTemplate>
            <asp:HiddenField ID="hidUserAchievementInfoId" runat="server" Value='<%# Bind("UserAchievementInfoId") %>' />
            <asp:HiddenField ID="hidUserIdField" runat="server" Value='<%# Bind("UserId") %>' />
            <tr>
                <td class="style1">
                    <asp:Label ID="AwardLabel" runat="server" Text="Award "></asp:Label>
                </td>
                <td>
                    <asp:Label ID="lblAward" runat="server" Text='<%# Bind("Awards") %>'></asp:Label>
                </td>
            </tr>
            <tr>
                <td class="style1">
                    <asp:Label ID="FieldofAwardLabel" runat="server" Text="Field of Award "></asp:Label>
                </td>
                <td>
                    <asp:Label ID="lblFieldofAward" runat="server" Text='<%# Bind("FieldofAward") %>'></asp:Label>
                </td>
            </tr>
            <tr>
                <td class="style1">
                    <asp:Label ID="TournamentLabel" runat="server" Text="Tournament "></asp:Label>
                </td>
                <td>
                    <asp:Label ID="lblTournament" runat="server" Text='<%# Bind("Tournament") %>'></asp:Label>
                </td>
            </tr>
            <tr>
                <td class="style1">
                    <asp:Label ID="AwardYearLabel" runat="server" Text="Award Year "></asp:Label>
                </td>
                <td>
                    <asp:Label ID="AwardYear" runat="server" Text='<%# Bind("AwardYear") %>'></asp:Label>
                </td>
            </tr>
            <tr>
                <td class="style1">
                    <asp:Label ID="AwardDescriptionLabel" runat="server" Text="Description "></asp:Label>
                </td>
                <td>
                    <asp:Label ID="lblAwardDescription" runat="server" Text='<%# Bind("AwardDescription") %>'></asp:Label>
                </td>
            </tr>
            <tr>
                <td class="style1">
                    <asp:LinkButton ID="EditButton" runat="server" CommandName="Edit" Text="Edit"></asp:LinkButton>
                </td>
                <td>
                    <asp:LinkButton ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete"></asp:LinkButton>
                </td>
            </tr>
        </ItemTemplate>

对象数据中使用的删除方法 源的删除命令

    public void DeleteUserAchievementInfo(UserAchivementInfoBO BOInstance)
    {
        try
        {
    Int64 UserAchievementInfoId=BOInstance.UserAchievementInfoId
            objUserBasicInfoServiceClient.DeleteUserAchievementInfo(UserAchievementInfoId);
        }
        catch (Exception ex)
        {
            HandleException.LogError(ex);
        }
    }

i have one Listview in my Usercontrol & 1 objectdatasource binded with the ListView.
now in objectdatasource's Deletemethod i have taken businessobject as argument but at runtime i am not getting value in my businessobject's properties...

i also tried to use "Bind" instead of "eval" in ItemTemplate. but not getting any value at runtime in my DeleteMethod provided in objectdatasource's Deletecommand...
can anybody help to know weather i am mising anything or what?

my Listview's ItemTemplate

 <ItemTemplate>
            <asp:HiddenField ID="hidUserAchievementInfoId" runat="server" Value='<%# Bind("UserAchievementInfoId") %>' />
            <asp:HiddenField ID="hidUserIdField" runat="server" Value='<%# Bind("UserId") %>' />
            <tr>
                <td class="style1">
                    <asp:Label ID="AwardLabel" runat="server" Text="Award "></asp:Label>
                </td>
                <td>
                    <asp:Label ID="lblAward" runat="server" Text='<%# Bind("Awards") %>'></asp:Label>
                </td>
            </tr>
            <tr>
                <td class="style1">
                    <asp:Label ID="FieldofAwardLabel" runat="server" Text="Field of Award "></asp:Label>
                </td>
                <td>
                    <asp:Label ID="lblFieldofAward" runat="server" Text='<%# Bind("FieldofAward") %>'></asp:Label>
                </td>
            </tr>
            <tr>
                <td class="style1">
                    <asp:Label ID="TournamentLabel" runat="server" Text="Tournament "></asp:Label>
                </td>
                <td>
                    <asp:Label ID="lblTournament" runat="server" Text='<%# Bind("Tournament") %>'></asp:Label>
                </td>
            </tr>
            <tr>
                <td class="style1">
                    <asp:Label ID="AwardYearLabel" runat="server" Text="Award Year "></asp:Label>
                </td>
                <td>
                    <asp:Label ID="AwardYear" runat="server" Text='<%# Bind("AwardYear") %>'></asp:Label>
                </td>
            </tr>
            <tr>
                <td class="style1">
                    <asp:Label ID="AwardDescriptionLabel" runat="server" Text="Description "></asp:Label>
                </td>
                <td>
                    <asp:Label ID="lblAwardDescription" runat="server" Text='<%# Bind("AwardDescription") %>'></asp:Label>
                </td>
            </tr>
            <tr>
                <td class="style1">
                    <asp:LinkButton ID="EditButton" runat="server" CommandName="Edit" Text="Edit"></asp:LinkButton>
                </td>
                <td>
                    <asp:LinkButton ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete"></asp:LinkButton>
                </td>
            </tr>
        </ItemTemplate>

Delete Method used in objectdata
source's Deletecommand

    public void DeleteUserAchievementInfo(UserAchivementInfoBO BOInstance)
    {
        try
        {
    Int64 UserAchievementInfoId=BOInstance.UserAchievementInfoId
            objUserBasicInfoServiceClient.DeleteUserAchievementInfo(UserAchievementInfoId);
        }
        catch (Exception ex)
        {
            HandleException.LogError(ex);
        }
    }

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

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

发布评论

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

评论(1

青芜 2024-08-23 12:01:37

尝试将业务对象关键字段(例如 id、key...)添加到列表视图 datakeynames 属性。通过这样做,至少可以得到删除事件中的键值。

Try to add the business object key field(e.g id, key...) to the listview datakeynames property. By doing this, you can at least get the key value in the deleting event.

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