Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Building Controls / December 2004

Tip: Looking for answers? Try searching our database.

Cannot keep selected value in control?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Francois Soucy - 30 Dec 2004 02:16 GMT
Hi all!

       I've begin my first webcontrol with asp.net. I've not build
everything but the first part is done except that the dropdownlist did not
keep is selected value between postback. I've reed many tutorial but no one
can explain me what's wrong with my code. Someone could give me a little
help?

Thanks,
Francois

######
Public Class RssControl
       Inherits Panel
       Implements INamingContainer

       Protected CboRssDrop As New DropDownList
       Private _DataTextField As String
       Private _DataValueField As String
       Private _DataSource As Object

#Region "Property"
       Public Property DataTextField() As String
           Get
               Return Me._DataTextField
           End Get
           Set(ByVal Value As String)
               Me._DataTextField = Value
               Me.CboRssDrop.DataTextField = Value
           End Set
       End Property

       Public Property DataValueField() As String
           Get
               Return Me._DataValueField
           End Get
           Set(ByVal Value As String)
               Me._DataValueField = Value
               Me.CboRssDrop.DataValueField = Value
           End Set
       End Property

       Public Property DataSource() As Object
           Get
               Return Me._DataSource
           End Get
           Set(ByVal Value As Object)
               Me._DataSource = Value
               Me.CboRssDrop.DataSource = Value
           End Set
       End Property
#End Region

#Region "DataBind"
       Public Overrides Sub DataBind()
           Me.CboRssDrop.DataBind()
       End Sub
#End Region

#Region "OnInit"
       Protected Overrides Sub OnInit(ByVal e As EventArgs)
           Me.CboRssDrop.AutoPostBack = True
           Me.CboRssDrop.EnableViewState = True
           MyBase.OnInit(e)
       End Sub 'OnInit
#End Region

#Region "CreateChildCtl"
       Protected Overrides Sub CreateChildControls()
           Me.AfficherControl()
       End Sub 'CreateChildControls
#End Region

#Region "AfficherCtl"
       Protected Sub AfficherControl()
           Me.Controls.Add(New LiteralControl("<table class=""Article""
cellSpacing=""0"" cellPadding=""0"" width=""240"" border=""0"">"))
           Me.Controls.Add(New LiteralControl("<TR><TD
Class=""ArticleTitre"">"))
           Me.CboRssDrop.Width = Unit.Percentage(90)
           Me.Controls.Add(Me.CboRssDrop)
           Me.Controls.Add(New LiteralControl("</td></TR><tr><td
class=""ArticleTexte"">###Text###</td></TR>"))
           Me.Controls.Add(New LiteralControl("<TR><td
class=""ArticleSignature"">###SIGNATURE###</td></TR>"))
           Me.Controls.Add(New LiteralControl("</TABLE>"))
           Me.Controls.Add(New LiteralControl("<table class=""deco1""
cellSpacing=""0"" cellPadding=""0"" width=""200"" align=""center""
border=""0"">"))
           Me.Controls.Add(New
LiteralControl("<TR><TD>&nbsp;</TD></TR></TABLE>"))
       End Sub
#End Region
End Class
John Saunders - 30 Dec 2004 03:54 GMT
> Hi all!
>
[quoted text clipped - 3 lines]
> one can explain me what's wrong with my code. Someone could give me a
> little help?

This can happen if your caller calls DataBind both on the initial request
and on PostBack.

John Saunders

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.