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

J

John Smith

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>

Any ideas?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top