Got more questions? Find advice on: SQL | XML | Regular Expressions | Windows
in Search
Welcome to AspAdvice Sign in | Join | Help

DropDownLists in ListView

Last post 05-16-2008, 10:09 AM by António. 0 replies.
Sort Posts: Previous Next
  •  05-16-2008, 10:09 AM 42332

    DropDownLists in ListView

    Hello!

    I'm starting with ListView and I have a problem using DropDownLists in the InsertItemTemplate. I have the code as follows:

    <asp:DropDownList ID="DropDownList3" runat="server" AppendDataBoundItems="True" DataSourceID="LinqDataSource4" DataTextField="Disciplina" DataValueField="Cod"

    SelectedValue='<%# Bind("Cod") %>' >

    SelectedValue='<%# Bind("Cod") %>' >

    <asp:ListItem></asp:ListItem>

    <asp:ListItem></asp:ListItem>

    </asp:DropDownList>

    </asp:DropDownList>

    <asp:LinqDataSource ID="LinqDataSource4" runat="server" ContextTypeName="DSIDigitalDataContext" OrderBy="Disciplina"

    Select="new (Cod, Disciplina)" TableName="Unidades_SAs">

    <asp:LinqDataSource ID="LinqDataSource4" runat="server" ContextTypeName="DSIDigitalDataContext" OrderBy="Disciplina"

    Select="new (Cod, Disciplina)" TableName="Unidades_SAs">

    Select="new (Cod, Disciplina)" TableName="Unidades_SAs">

    </asp:LinqDataSource>

    </asp:LinqDataSource>

    and I get the following error when I start the app:

    InvalidOperationException was unhandled by user code - Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.

    In the same ListView I use a similar DropDownList in the EditItemTemplate and I have no problem.

    I'll appreciate your help.

    Sorry if this is not the correct place to speak about this issue.

    Regards.

    António

    Filed under:
View as RSS news feed in XML