473,395 Members | 1,726 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,395 software developers and data experts.

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


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>
Jun 6 '06 #1
0 2264

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

Similar topics

0
by: Dave | last post by:
Can I create a user control so that when I drop it on the web form I can put text between the start and end tags as listed <uc1:KeyFeatures id="KeyFeatures1" runat="server"...
6
by: Richard | last post by:
Dim index As Integer = lbSysteem.FindStringExact(strSysteem) basicly i want to return the value but as the examples show on the MSDN library, nothings wrong with the code? if FindStringExact...
20
by: Guadala Harry | last post by:
In an ASCX, I have a Literal control into which I inject a at runtime. litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID); This works great as long as the contains just...
3
by: Brano | last post by:
HI all, I have a problem i have a web application that was working fine and this morning when i run it and click on a button that does Reponse.Redirect to a page i get this error : Server...
6
by: Joe | last post by:
I know that the Literal control will not render a <span> tag so I can not format its text. Other than this, what is the difference betwen the Literal control and the LiteralControl Control? How...
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: John Smith | last post by:
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"...
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...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.