473,382 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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


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_SelectedIndexChan ged">
<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_SelectedIndexChan ged">
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?
Jun 7 '06 #1
0 3307

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: .Net Sports | last post by:
IN a datagrid code behind, I'm getting a "Specified cast is not valid" error price = (Decimal)(rowData); which was initialized as: Decimal price;
6
by: blash | last post by:
Can someone help me? I really don't have a clue. My company staff told me they often got such error: "Object reference not set to an instance of an object." when they are in search result page...
1
by: Alan Silver | last post by:
Hello, I am just converting a 1.1 web site to use version 2.0 of the framework and have run into a weird problem trying to add a skin file. I set up a theme, and moved the CSS file in there,...
0
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this...
0
by: apenly | last post by:
Hi all- I'm trying to Render a TreeView in a custom control, but I'm receiving a NullReferenceException at runtime. If I put the TreeView on the page it works fine, but as soon as I try to...
7
by: Jim in Arizona | last post by:
Using this: <asp:ListItem Value="0"</asp:ListItem> as long as I have a value listed and leave the area between the tags blank, when viewed the DropDownList will show a 0 as a choice. I want it...
0
by: forumaic | last post by:
Hello, I am trying to export data to excel from datagrid, and I am getting an error: "The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)." ...
4
by: Neo Geshel | last post by:
Just moved to C# from VB.NET, frustrated to hell and back by inability to get much-copied (from about 20+ different resources) literal example to work. Master Page content: <meta...
0
by: tasmontique | last post by:
I hope someone can help me. I have an error that I can not seem to figure out. All I need is an unbound dropdownlist to navigate to urls withing the website. I have gotten as far as to populate field...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.