Results 1 to 2 of 2

Thread: Textbox Data Binding Problem

  1. #1

    Thread Starter
    Hyperactive Member shyguyjeff's Avatar
    Join Date
    Jul 2007
    Location
    City of Durian
    Posts
    289

    Textbox Data Binding Problem

    Hi Everyone, i need a hand on how do i set my initial value for textbox as blank. I tried to I load my textbox a data coming from my database but what my problem is that I need to set my default value for textbox as blank because everytime I load the forms the textbox will be filled immediately with data. This is how I bind my textbox and combobox after loading from database.
    Code:
    cbxJoblvl.DataSource = myDataSet.DefaultViewManager;
                cbxJoblvl.DisplayMember = "Joblevel.lvl";
                cbxJoblvl.SelectedIndex = -1;
                txtLvlName.DataBindings.Add("Text", myDataSet.DefaultViewManager, "Joblevel.lvlname");

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Textbox Data Binding Problem

    First of all, it's pointless binding to the DefaultViewManager of a DataSet, just as it's pointless to bind to the DefaultView of a DataTable. When binding to a DataSet or DataTable, it's the DefaultView of each DataTable that the data comes from anyway.

    As for the question, I just tested and even setting the SelectedIndex after binding the TextBox didn't help. I think that you're just going to have to explicitly clear the TextBox if you want no record selected.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width