I have an entity called PendingPartners which has a navigation property to the Residents entity. I’m returning information from these objects like so:
Dim getSent = (From p In dbContext.PendingPartners _
Join r In dbContext.Residents _
On p.people_id_des Equals r.people_code_id _
Where p.people_id_ini = people_id _
Where p.semester = semester _
Where p.year = year _
Select r.person_name).Distinct
rptrSent.DataSource = getSent
rptrSent.DataBind()
As you can see above, the data is then bound to a repeater control the code for which looks like this:
<asp:Repeater ID="rptrSent" runat="server">
<ItemTemplate>
<asp:Button ID="btnDeletePartner" runat="server"
Text="<%# Container.DataItem %>" />
<br />
</ItemTemplate>
</asp:Repeater>
Now, I want to make it so that when someone clicks the Delete button it actually deletes that record from the entity – just the PendingPartner portion, no need to rollup to the Resident object.
Now, to do this I think I need to:
- Add the ID column to the EntitySQL query, e.g. Select p.id, r.person_name.
- Bind the ID column to the repeater as say CommandName or CommandArgument.
- Change the way the binding is for the text – since the repeater now has two columns.
I know how to update the EntitySQL, but I always get confused with then getting this info. into the repeater…help?
I think your need to use the bind function in the repeater
The Button’s Text uses “person_name” and the command argument uses the “id” and the command name would be “delete”.
like so: