Wrox Programmer Forums
|
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 3rd, 2004, 12:29 PM
Authorized User
 
Join Date: Oct 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default DropDownList problem

I have file called "test.aspx".
In "test.aspx" I have this code:

<asp:DropDownList runat="server" id="chooseDay" >
<asp:ListItem value='<%#strday%>' Selected=True ><%#strday%> </asp:ListItem>
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
.
.
.
</asp:DropDownList>


In "test.aspx.vb" I have this code:

    Public strday As Integer = DateTime.Today.Day()
    Public strmounth As Integer = DateTime.Today.Month()
    Public stryear As Integer = DateTime.Today.Year()

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

   Page.DataBind()
END sub


I get this Error massage
Parser Error Message: Code blocks are not supported in this context.


What's the problem and how to fix it??

 
Old November 4th, 2004, 05:59 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi lior,
you recive that error because of the red text
<asp:ListItem value='<%#strday%>' Selected=True ><%#strday%> </asp:ListItem>
Secondly,you cant bind ListItem objects ... if you do you will face this error,
'System.Web.UI.WebControls.ListItem' does not contain a definition for 'DataBinding'
HtH.

--------------------------------------------
Mehdi.:)
 
Old September 22nd, 2005, 05:29 AM
Registered User
 
Join Date: Sep 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

'System.Web.UI.WebControls.ListItem' does not contain a definition for 'DataBinding'

I'm getting following abouve error in the following code

<ItemTemplate>
   <asp:DropDownList ID="ddlbContractType" Runat="server">
    <asp:ListItem Value="eContract"/>
    <asp:ListItem Value="Print" Selected='<%# DataBinder.Eval(Container.DataItem, "AType") %>/>
   </asp:DropDownList>
</ItemTemplate>
 
Old September 22nd, 2005, 10:49 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Use the properties window to set the databindings properties for the drop down list.

 
Old September 29th, 2005, 04:08 AM
Registered User
 
Join Date: Sep 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Still i'm getting the same error message
----------------------------------------
Quote:
quote:Originally posted by jbenson001
 Use the properties window to set the databindings properties for the drop down list.






Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in dropdownlist premnaath ASP.NET 2.0 Professional 2 November 29th, 2007 10:01 AM
Dropdownlist Problem monika.vasvani ASP.NET 1.0 and 1.1 Professional 2 November 11th, 2006 09:24 AM
DropDownList Problem cmw231 ASP.NET 2.0 Professional 0 July 14th, 2006 08:44 AM
Problem with dropdownlist somnath.kartic ASP.NET 1.0 and 1.1 Basics 3 February 8th, 2006 01:59 AM
dropdownlist problem naresh.net ASP.NET 1.0 and 1.1 Basics 4 July 7th, 2005 01:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.