Hi
I thought I was trying to do something very simple but I'm have a lot of
trouble trying to do the following.
<asp:FormView ID="fvGroups" runat="server" DataKeyNames="G roupID"
DataSourceID="o dsGroups"
DefaultMode="In sert" Visible="false" OnItemCommand=" fvGroups_ItemCo mmand">
<InsertItemTemp late>
<asp:DropDownLi st ID="ddlEditMode " runat="server"
OnInit="ddlEdit Mode_Init" SelectedValue=' <%# Bind("EditMode" ) %>'>
<asp:ListItem Selected="True" Value="0" Text="Select... " ></asp:ListItem>
</asp:DropDownLis t>
</InsertItemTempl ate>
</asp:FormView>
....
protected void ddlEditMode_Ini t(object sender, EventArgs e)
{
DropDownList ddlEditMode = sender as DropDownList;
ddlEditMode.Ena bleViewState = false;
ddlEditMode.App endDataBoundIte ms = true;
ddlEditMode.Dat aSource = myList; // an OrderedDictiona ry object
ddlEditMode.Dat aTextField = "value";
ddlEditMode.Dat aValueField = "key";
// Bind the data to the control.
ddlEditMode.Dat aBind();
}
When I add SelectedValue=' <%# Bind("EditMode" ) %>'to the DroupDownList I
get this error.
"System.Invalid OperationExcept ion: Databinding methods such as Eval(),
XPath(), and Bind() can only be used in the context of a databound control."
I just want to save the value to the ObjectDataSourc e InsertParameter s.
Surely this is a very standard requirement?
Thanks
Andrew