How do I DataBind to a control when Textbox.visible=false

Discussion in 'ASP .Net Datagrid Control' started by Rob Dob, Mar 20, 2006.

  1. Rob Dob

    Rob Dob Guest

    Hi,

    I'm not sure if I going about this the correct way.

    I have some databound TextBox's displayed on a winform that are bound to my
    BindingSource. When I make modifications to any of these textboxes and
    then try to save these changes everything works fine. However I have a
    requirement to programmically change the values of some of the other fields
    which are part of this same BindingSource. My solution was to create some
    additional TextBoxes and then change the property of those textboxes from
    visible=true to visible=false, and then programmically change the Text
    values of these controls from within my code. The problem is that none of
    these changes are being updated for the controls where I have set Visible
    =false.

    How do I programmically change the values of some of the fields attached to
    my BindingSource for which I don't wish to display on my winform, But I
    still need the BindingSource to recognize these as changes and still treat
    them the same as changes made manually to the other visible=true textboxes.

    Thanks,
     
    Rob Dob, Mar 20, 2006
    #1
    1. Advertising

  2. Rob Dob

    Eric Smith Guest

    I don't know if I understand your situation completely, but it seems like
    you should be able to just change the fields directly on the underlying
    object instead of trying to go through a TextBox.

    I don't know if you're binding to some regular object or some other data
    source, but when I had a class where changing one property also affected
    other properties, I implemented INotifyPropertyChanged and fired the event
    for all the properties that changed.

    --Eric

    "Rob Dob" <> wrote in message
    news:...
    > Hi,
    >
    > I'm not sure if I going about this the correct way.
    >
    > I have some databound TextBox's displayed on a winform that are bound to
    > my BindingSource. When I make modifications to any of these textboxes
    > and then try to save these changes everything works fine. However I have
    > a requirement to programmically change the values of some of the other
    > fields which are part of this same BindingSource. My solution was to
    > create some additional TextBoxes and then change the property of those
    > textboxes from visible=true to visible=false, and then programmically
    > change the Text values of these controls from within my code. The problem
    > is that none of these changes are being updated for the controls where I
    > have set Visible =false.
    >
    > How do I programmically change the values of some of the fields attached
    > to my BindingSource for which I don't wish to display on my winform, But I
    > still need the BindingSource to recognize these as changes and still treat
    > them the same as changes made manually to the other visible=true
    > textboxes.
    >
    > Thanks,
    >
    >
    >
     
    Eric Smith, Mar 23, 2006
    #2
    1. Advertising

  3. Rob Dob

    Rob Dob Guest

    Hi



    Thank you for the reply...

    ">fields directly on the underlying object instead of trying to go through a
    TextBox."

    How do I go about doing this. within the BindingSource, the Dataset,
    where?



    "Eric Smith" <> wrote in message
    news:...
    >I don't know if I understand your situation completely, but it seems like
    >you should be able to just change the fields directly on the underlying
    >object instead of trying to go through a TextBox.
    >
    > I don't know if you're binding to some regular object or some other data
    > source, but when I had a class where changing one property also affected
    > other properties, I implemented INotifyPropertyChanged and fired the event
    > for all the properties that changed.
    >
    > --Eric
     
    Rob Dob, Mar 30, 2006
    #3
  4. Rob Dob

    Ranko Guest

    Rob Dob wrote:
    > Hi,
    >
    > I'm not sure if I going about this the correct way.
    >
    > I have some databound TextBox's displayed on a winform that are bound to my
    > BindingSource. When I make modifications to any of these textboxes and
    > then try to save these changes everything works fine. However I have a
    > requirement to programmically change the values of some of the other fields
    > which are part of this same BindingSource. My solution was to create some
    > additional TextBoxes and then change the property of those textboxes from
    > visible=true to visible=false, and then programmically change the Text
    > values of these controls from within my code. The problem is that none of
    > these changes are being updated for the controls where I have set Visible
    > =false.
    >
    > How do I programmically change the values of some of the fields attached to
    > my BindingSource for which I don't wish to display on my winform, But I
    > still need the BindingSource to recognize these as changes and still treat
    > them the same as changes made manually to the other visible=true textboxes.
    >
    > Thanks,
    >
    >
    >

    If I understand correctly your problem, you can try this(for example):
    for untyped dataset:

    Dim rowindex As Integer
    rowindex = customersBindingSource.Position

    customersDataset.Tables("Customers").Rows(rowindex)("LastName") = "Smith"

    or for typed dataset:
    customersDataset.Customers(rowindex).LastName = "Smith"

    or
    customersDataset.Customers(rowindex).LastName = LastNameTextBox.Text
     
    Ranko, Apr 1, 2006
    #4
  5. Rob Dob

    Tatyana Guest

    Hello,

    I had similar problem with this... I know it's better to work directly with DataSet Data but...

    Well here is the answer :

    http://fredrik.nsquared2.com/viewpost.aspx?PostID=201

    Hope this helps,

    Thank you,

    Tatyana





    "Rob Dob" <> wrote in message news:...
    > Hi,
    >
    > I'm not sure if I going about this the correct way.
    >
    > I have some databound TextBox's displayed on a winform that are bound to my
    > BindingSource. When I make modifications to any of these textboxes and
    > then try to save these changes everything works fine. However I have a
    > requirement to programmically change the values of some of the other fields
    > which are part of this same BindingSource. My solution was to create some
    > additional TextBoxes and then change the property of those textboxes from
    > visible=true to visible=false, and then programmically change the Text
    > values of these controls from within my code. The problem is that none of
    > these changes are being updated for the controls where I have set Visible
    > =false.
    >
    > How do I programmically change the values of some of the fields attached to
    > my BindingSource for which I don't wish to display on my winform, But I
    > still need the BindingSource to recognize these as changes and still treat
    > them the same as changes made manually to the other visible=true textboxes.
    >
    > Thanks,
    >
    >
    >
     
    Tatyana, May 12, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alejandro Penate-Diaz

    if (control.visible == false) viewstate disabled?

    Alejandro Penate-Diaz, Mar 4, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    2,484
    Alejandro Penate-Diaz
    Mar 4, 2005
  2. Nick Stansbury
    Replies:
    6
    Views:
    482
    Nick Stansbury
    Apr 11, 2005
  3. Michael
    Replies:
    0
    Views:
    233
    Michael
    Dec 29, 2003
  4. Andrea Williams

    User control not visible when setting .Visible = true;

    Andrea Williams, Jan 26, 2004, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    544
    Andrea Williams
    Jan 28, 2004
  5. Jurjen de Groot
    Replies:
    0
    Views:
    318
    Jurjen de Groot
    May 19, 2008
Loading...

Share This Page