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

Cannot assign property of a WebControl

Hi,

I have a strange behavior with a webcontrol. It seems that under some
conditions, it's not possible to assign a value to a property.
theControl is a ListBox

theControl.DataSource = someTable
theControl.SelectedValue = "1" ' this value belongs to someTable
theControl.DataBind()

The property SelectedValue does not change. Can you see why ?

Thanks.
Fred
Nov 18 '05 #1
2 967
"Frédéric Mayot" <to**@toto.com> wrote in message
news:uD**************@TK2MSFTNGP10.phx.gbl...
Hi,

I have a strange behavior with a webcontrol. It seems that under some
conditions, it's not possible to assign a value to a property.
theControl is a ListBox

theControl.DataSource = someTable
theControl.SelectedValue = "1" ' this value belongs to someTable
theControl.DataBind()

The property SelectedValue does not change. Can you see why ?


SelectedValue selects the item with the given value. Before you do the
DataBind, the list control has no items to select. Try doing the DataBind
first.
--
John Saunders
johnwsaundersiii at hotmail
Nov 18 '05 #2
In ASP.NET applications, until you do not call the DataBind method in a web control the items are not created (even if you have set the DataSource propoerty). Once you call this method you can reference any item since they have already been created.

Alan Ferrandiz
MCDBA, MCT, MSF Practitioner

"Frédéric Mayot" <to**@toto.com> escribió en el mensaje news:uD**************@TK2MSFTNGP10.phx.gbl...
Hi,

I have a strange behavior with a webcontrol. It seems that under some
conditions, it's not possible to assign a value to a property.
theControl is a ListBox

theControl.DataSource = someTable
theControl.SelectedValue = "1" ' this value belongs to someTable
theControl.DataBind()

The property SelectedValue does not change. Can you see why ?

Thanks.
Fred

Nov 18 '05 #3

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

Similar topics

3
by: Earl Teigrob | last post by:
I have a class that has some fields and properties that I want to serialize. However, one of the fields is of type System.Web.UI.Webcontrols.Webcontrol and it will not serialize so I want to mark...
5
by: Nathan Sokalski | last post by:
When running a page I am working on, I recieve the following error: Cannot use a leading .. to exit above the top directory. I suspect this has something to do with the problem I posted in a...
0
by: Andrea | last post by:
I've built my own webcontrol to make page navigation. One of control's property is recordCount that is used to know how many record should be take in mind to print out the pages number. The...
1
by: shapper | last post by:
Hello, I have a class where I created various controls. One of the controls have a property which is a generic list of WebControl. Then in web site page I have something like: Dim a As New...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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,...

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.