Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. TextBox.Clear() won't clear column that it Bind to.

TextBox.Clear() won't clear column that it Bind to.

Scheduled Pinned Locked Moved C#
help
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kakarato
    wrote on last edited by
    #1

    I bind text box below with a string typed datarow where the column i'm going to bind is DateTime. Below id the code: this.txtDate.DataBindings.Add("Text", m_DataRow, "END_DT", true, DataSourceUpdateMode.OnPropertyChanged, null, "dd/MM/yyyy"); when i click on a chkbox event below fired: private void chkbox_CheckedChanged(object sender, EventArgs e) { Boolean isChecked = ((CheckBox)sender).Checked; if (!isChecked) { this.txtDate.Clear() } // Line below will clear the text in text box an also clear the m_DataRow.END_DT. //if (!isChecked) //{ // this.txtDate.Clear() // m_DataRow.SetEND_DTNull() //} } Date that show in the textbox is clear. How ever the date time still exist in m_DataRow.END_DT. I Thought when i set the txtDate.Clear it should also clear the m_DataRow.END_DT some how it won't work. Please help.

    L J 2 Replies Last reply
    0
    • K kakarato

      I bind text box below with a string typed datarow where the column i'm going to bind is DateTime. Below id the code: this.txtDate.DataBindings.Add("Text", m_DataRow, "END_DT", true, DataSourceUpdateMode.OnPropertyChanged, null, "dd/MM/yyyy"); when i click on a chkbox event below fired: private void chkbox_CheckedChanged(object sender, EventArgs e) { Boolean isChecked = ((CheckBox)sender).Checked; if (!isChecked) { this.txtDate.Clear() } // Line below will clear the text in text box an also clear the m_DataRow.END_DT. //if (!isChecked) //{ // this.txtDate.Clear() // m_DataRow.SetEND_DTNull() //} } Date that show in the textbox is clear. How ever the date time still exist in m_DataRow.END_DT. I Thought when i set the txtDate.Clear it should also clear the m_DataRow.END_DT some how it won't work. Please help.

      L Offline
      L Offline
      Le centriste
      wrote on last edited by
      #2

      Did you call m_DataRow.AcceptChanges()? On a side note, if the user unchecks the button, do not clear the text box, just make it read-only and ignore its content. If the user changes his mind, just make it editable again and he won't have to re-enter it.

      ----- If atheism is a religion, then not collecting stamps is a hobby. -- Unknown

      1 Reply Last reply
      0
      • K kakarato

        I bind text box below with a string typed datarow where the column i'm going to bind is DateTime. Below id the code: this.txtDate.DataBindings.Add("Text", m_DataRow, "END_DT", true, DataSourceUpdateMode.OnPropertyChanged, null, "dd/MM/yyyy"); when i click on a chkbox event below fired: private void chkbox_CheckedChanged(object sender, EventArgs e) { Boolean isChecked = ((CheckBox)sender).Checked; if (!isChecked) { this.txtDate.Clear() } // Line below will clear the text in text box an also clear the m_DataRow.END_DT. //if (!isChecked) //{ // this.txtDate.Clear() // m_DataRow.SetEND_DTNull() //} } Date that show in the textbox is clear. How ever the date time still exist in m_DataRow.END_DT. I Thought when i set the txtDate.Clear it should also clear the m_DataRow.END_DT some how it won't work. Please help.

        J Offline
        J Offline
        Justin Perez
        wrote on last edited by
        #3

        Try using txtDate.DataBindings.Remove to remove the databinding, then clear the textbox.

        I get all the news I need from the weather report.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups