You have to specify in the DetailsView control the Item events with something like this:
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="AgentID"
OnItemUpdated="Agency_ItemUpdated"
OnItemInserted="Agency_ItemInserted"
OnItemDeleted="Agency_ItemDeleted" ...
and then rebind your drop down list data in the events with your code with something like this:
protected void Agency_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
{
drpAgencies.DataBind();
}
protected void Agency_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
{
drpAgencies.DataBind();
}
protected void Agency_ItemDeleted(object sender, DetailsViewDeletedEventArgs e)
{
drpAgencies.DataBind();
}
Make sure you use the DetailsViewDeletedEventArgs so the item events will fire from the DetailsView control.
--Harry
|