带有对象数据源删除的列表视图不起作用
我的用户控件中有一个列表视图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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试将业务对象关键字段(例如 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.