0 Replies - 1130 Views - Last Post: 09 June 2014 - 09:53 AM Rate Topic: -----

#1 itortu  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 09-June 14

details view, databinding, dropdownlist

Posted 09 June 2014 - 09:53 AM

my details view is linked to the selected value of a drop down list. it all works fine, but when the details view enters insert mode, one of the things that happen in the code behind is clearing the drop down values.

If dvRecipeItem.CurrentMode = DetailsViewMode.Insert Then
ddRecipeItemNumber.Items.Clear()
End If


but if the insert event gets cancelled, then this happens to the drop down

If dvRecipeItem.CurrentMode = DetailsViewMode.ReadOnly Then
ddRecipeItemNumber.DataBind()
End If


then the drop down goes back to contain all the values from datasource. but what happens to the details view is that instead that picking up the value from the drop down list, it goes to the default value = 1 that is specified in the entity datasource, and if I remove that default value, and then try to insert a new item, and cancel before saving it, then the details view disappears although the dropdownlist does contain a value. seems like it is not binding back.

<asp:EntityDataSource 
ID="EntityDataSource_RecipeItemDetail" 
runat="server" 
ConnectionString="name=OLTPEntities" 
DefaultContainerName="OLTPEntities" 
EnableFlattening="False" 
EntitySetName="RefineRecipe" 
Where="it.Id = @RecipeId" 
EnableDelete="True" 
EnableInsert="True" 
EnableUpdate="True" 
EntityTypeFilter="RefineRecipe">
<WhereParameters>
<asp:ControlParameter 
ControlID="ddRecipeItemNumber" 
DbType="Int32" 
DefaultValue="1" 
Name="RecipeId" 
PropertyName="SelectedValue" />
</WhereParameters>
</asp:EntityDataSource>


I would like to ask for help in order to figure out how to assign the drop down value to the details view on this event insert/ cancel
Any help would be nice, really.
Thank you very much.


Is This A Good Question/Topic? 0
  • +

Page 1 of 1