我的Usercontrol&中有一个Listview 1个与ListView绑定的objectdatasource。 现在在objectdatasource的Deletemethod我已经将businessobject作为参数,但在运行时我没有在我的businessobject的属性中获得价值......
我还尝试在ItemTemplate中使用“Bind”而不是“eval”。但是在objectdatasource的Deletecommand中提供的DeleteMethod中没有在运行时获取任何值... 任何人都可以帮助了解天气我正在做什么或什么?
我的Listview的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>
删除objectdata中使用的方法 source的Deletecommand
public void DeleteUserAchievementInfo(UserAchivementInfoBO BOInstance)
{
try
{
Int64 UserAchievementInfoId=BOInstance.UserAchievementInfoId
objUserBasicInfoServiceClient.DeleteUserAchievementInfo(UserAchievementInfoId);
}
catch (Exception ex)
{
HandleException.LogError(ex);
}
}
答案 0 :(得分:0)
尝试将业务对象键字段(例如id,key ...)添加到listview datakeynames属性。通过这样做,您至少可以在删除事件中获取键值。