473,748 Members | 9,913 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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


This is what I am trying to do:

<asp:datagrid id="DataGrid1" runat="server" AutoGenerateCol umns="False">
<Columns>
<asp:BoundColum n Visible="False" DataField="id" ReadOnly="True"
HeaderText="ID" ></asp:BoundColumn >
<asp:TemplateCo lumn HeaderText="O">
<ItemTemplate >
<asp:DropDownLi st id="cmbObdelaj " runat="server" AutoPostBack="T rue"
OnSelectedIndex Changed="DropDo wn_SelectedInde xChanged">
<asp:ListItem Selected="<%# GetSelected("P" ,
DataBinder.Eval (Container.Data Item, "S").ToString() ) %>"
Value="P">PPPP</asp:ListItem>
<asp:ListItem Selected="<%# GetSelected("D" ,
DataBinder.Eval (Container.Data Item, "S").ToString() ) %>"
Value="D">DDDD</asp:ListItem>
</asp:DropDownLis t>
</ItemTemplate>
</asp:TemplateCol umn>
<asp:datagrid >

Public Function GetSelected(ByV al 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.Lis tItemCollection '.
Source Error:
Line 7: <asp:DropDownLi st id="cmbObdelaj " runat="server"
AutoPostBack="T rue"
Line 8: OnSelectedIndex Changed="DropDo wn_SelectedInde xChanged">
Line 9: <asp:ListItem Selected="<%# GetSelected("P" ,
DataBinder.Eval (Container.Data Item, "S").ToString() ) %>"
Value="P">PPPP</asp:ListItem>
Line 10: <asp:ListItem Selected="<%# GetSelected("D" ,
DataBinder.Eval (Container.Data Item, "S").ToString() ) %>"
Value="D">DDDD</asp:ListItem>

Any ideas?
Jun 7 '06 #1
0 3332

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

Similar topics

3
3032
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
6126
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 then tried to access 2nd, or 3rd, etc page. The problem is it happens sometimes - sometimes when they clicked refresh button, then everything is ok. Now they told me it happens more frequently. but I have tried by myself many times and never got...
1
3714
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, no problem. I then changed one of the <img> tags in the master page to look like... <asp:Image ID="imgBsd" SkinId="imgBsd" runat="server" />
0
3579
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 OleDbParameterCollection" whenI try to write a new record. Delete and Modify work fine its just the add record function causes the error.
0
2486
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 render it within my control it crashes and burns. I've even tried placing it within another control (a PlaceHolder) and tried to render the PlaceHolder to no avail. Any ideas on how to fix this problem? Here's my code:
7
2774
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 to be blank. I've tried doing this: <asp:ListItem Value="0">&nbsp;</asp:ListItem>
0
1285
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. <% ... %>)." Error details: System.Web.HttpException was unhandled by user code Message="The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)."
4
2319
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 name="keywords" content="<asp:Literal ID="ltrlKeywords" Runat="server" />"></meta> Code-Behind:
0
2434
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 but I am stuck at this point. I am new to asp.net and this is my first website. Below is my code please help. Content controls have to be top-level controls in a content page or a nested master page that references a master page. ...
0
8987
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8826
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9534
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9316
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8239
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4597
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4867
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2211
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.