Binding Source Issue
-
Hi, Am developing a winforms app using C#. I am using binding source to design the forms. I have a combobox with items "Yes" and "No" depending on the selection of this I enable or disable a text box.
private void MyComboBox_TextChanged(object sender, EventArgs e)
{
if(MyComboBox.Text == "Yes")
{
textBox1.Enabled = true;
}
else
{
textox1.Text = ""; //am setting the text box to null if there is any text in it.
textbox1.Enabled = false;
}
}Lets say I have selected "Yes" from the combobox and entered text into the textbox1 and save the input on save_click. the value gets stored into the database. Now if I go back to the form and edit it....I now change the combox to "NO". It clears the text in the textbox1 to "". When i click on save...it saves the record. But the problem is that it is not updating it into the database.? Any idea why this is happening or do i need to include more code into the event. Help Appreciated..thanks,
-
Hi, Am developing a winforms app using C#. I am using binding source to design the forms. I have a combobox with items "Yes" and "No" depending on the selection of this I enable or disable a text box.
private void MyComboBox_TextChanged(object sender, EventArgs e)
{
if(MyComboBox.Text == "Yes")
{
textBox1.Enabled = true;
}
else
{
textox1.Text = ""; //am setting the text box to null if there is any text in it.
textbox1.Enabled = false;
}
}Lets say I have selected "Yes" from the combobox and entered text into the textbox1 and save the input on save_click. the value gets stored into the database. Now if I go back to the form and edit it....I now change the combox to "NO". It clears the text in the textbox1 to "". When i click on save...it saves the record. But the problem is that it is not updating it into the database.? Any idea why this is happening or do i need to include more code into the event. Help Appreciated..thanks,
You should be using the selected item changed event and not the Text Changed event. Also change your combo box to be of type DropDownList.
Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost
-
You should be using the selected item changed event and not the Text Changed event. Also change your combo box to be of type DropDownList.
Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost
Can you tell me how to update the database when the binding source is modified please? In this case the textBox text is being modified and I want to know how the selected item changed (i think ur trying to say SelectedIndexChanged event ?) and changing the property of the combobox to dropdownlist would solve this issue? Thanks,