Solved

Bind Property to Asp.net textbox

Posted on 2009-05-13
6
682 Views
Last Modified: 2012-05-06
I have a numerous textboxes and controls on my asp.net page. I also have properties that I fill based on the outcome of different class functions. Below is an example of a property in one of the classes of my site:
'User branch property
    Private Branch As String
    Public Property UserBranch() As String
        Get
            Return Branch
        End Get
        Set(ByVal UserBranch As String)
            Branch = UserBranch
        End Set
    End Property
Now, is there a way in asp.net to bind a textbox to this value such as databinding other than using txtbranch.text = userbranch in the page load event. Is there a way to tie this property to this value so that every time the page loads, then it will display the return value from the property. Any help would be greatly appreciated.
0
Comment
Question by:jpadkins49
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 10

Expert Comment

by:MaxOvrdrv2
ID: 24375038
txtbranch.DataSource=UserBranch
0
 
LVL 1

Author Comment

by:jpadkins49
ID: 24375398
Is there a datasource property for textbox controls in asp.net? I do not see one.
0
 
LVL 10

Expert Comment

by:MaxOvrdrv2
ID: 24375939
no... there is none... my bad... BUT... if you put the txtbranch.Text=UserBranch in the page load, wouldn't that load the text every time?

i don't understand what you're trying to do... you want the text to change on the fly without a post-back?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Accepted Solution

by:
MaxOvrdrv2 earned 500 total points
ID: 24375988
you could always define a datasource object, and then on the page load set the text to the datasource... but it's the same thing as calling it directly in the page load.
0
 
LVL 1

Author Comment

by:jpadkins49
ID: 24430606
I have set these values to load on the page load event, but they sometimes lose their values on the postback and I am not sure why.
0
 
LVL 10

Expert Comment

by:MaxOvrdrv2
ID: 24432302
how do you add the objects that hold the values?
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question