Literal content ('<asp:ListItem Selected="') is not allowed within a 'System.Web.UI.WebControls.List

Discussion in 'ASP .Net' started by John Smith, Jun 6, 2006.

  1. John Smith

    John Smith Guest

    This is what I am trying to do:

    <asp:datagrid id="DataGrid1" runat="server" AutoGenerateColumns="False">
    <Columns>
    <asp:BoundColumn Visible="False" DataField="id" ReadOnly="True"
    HeaderText="ID"></asp:BoundColumn>
    <asp:TemplateColumn HeaderText="O">
    <ItemTemplate>
    <asp:DropDownList id="cmbObdelaj" runat="server" AutoPostBack="True"
    OnSelectedIndexChanged="DropDown_SelectedIndexChanged">
    <asp:ListItem Selected="<%# GetSelected("P",
    DataBinder.Eval(Container.DataItem, "S").ToString()) %>"
    Value="P">PPPP</asp:ListItem>
    <asp:ListItem Selected="<%# GetSelected("D",
    DataBinder.Eval(Container.DataItem, "S").ToString()) %>"
    Value="D">DDDD</asp:ListItem>
    </asp:DropDownList>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:datagrid>

    Public Function GetSelected(ByVal expectedCode As String, ByVal realCode As
    String) As String
    If expectedCode = realCode Then
    Return "True"
    Else
    Return "False"
    End If
    End Function

    This is the error message:

    Parser Error
    Description: An error occurred during the parsing of a resource required to
    service this request. Please review the following specific parse error
    details and modify your source file appropriately.
    Parser Error Message: Literal content ('<asp:ListItem Selected="') is not
    allowed within a 'System.Web.UI.WebControls.ListItemCollection'.
    Source Error:
    Line 7: <asp:DropDownList id="cmbObdelaj" runat="server"
    AutoPostBack="True"
    Line 8: OnSelectedIndexChanged="DropDown_SelectedIndexChanged">
    Line 9: <asp:ListItem Selected="<%# GetSelected("P",
    DataBinder.Eval(Container.DataItem, "S").ToString()) %>"
    Value="P">PPPP</asp:ListItem>
    Line 10: <asp:ListItem Selected="<%# GetSelected("D",
    DataBinder.Eval(Container.DataItem, "S").ToString()) %>"
    Value="D">DDDD</asp:ListItem>
     
    John Smith, Jun 6, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RGF2ZQ==?=

    "Literal content is not allowed within a user control"?

    =?Utf-8?B?RGF2ZQ==?=, May 17, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    3,138
    =?Utf-8?B?RGF2ZQ==?=
    May 17, 2004
  2. Alan Silver
    Replies:
    1
    Views:
    7,365
    Alan Silver
    Jan 26, 2006
  3. John Smith
    Replies:
    0
    Views:
    1,358
    John Smith
    Jun 7, 2006
  4. Dave

    Literal content is not allowed within a CustomControl?

    Dave, Aug 2, 2006, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    724
  5. Ahsan Umair

    Literal content is not allowed within a UserControl

    Ahsan Umair, Jul 16, 2008, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    403
Loading...

Share This Page