Domanda

I have somewhat of a strange issue that I need help with. Given the following code snippet:

public partial class CliUpdate : Form
{       

    static DataRow cliRecord;
    static DataView cliView;

    public CliUpdate(DataRow dr)
    {
        InitializeComponent();
        cliRecord = dr;
        cliView = cliRecord.Table.DefaultView;          
        SetFieldValues();                       
    }               

    void SetFieldValues(){                  
        string recordid = cliRecord["recordid"].ToString();
        cliView.RowFilter = "recordid='" + recordid + "'";          
        tb_ClientName.DataBindings.Add("Text",cliView,"clientname");
        tb_basefolder.DataBindings.Add("Text",cliView,"basefolder");
        cb_CollectionOutput.DataBindings.Add("Text",cliView,"outputtype");
        nud_SmallBalance.DataBindings.Add("Value",cliView,"smallbalance");

On the form I have a textbox named tb_basefolder. If I actually type something in the textbox, the datarow field gets properly updated BUT if I give the textbox a value by setting the .Text property, the value does not get updated on the datarow (ie tb_basefolder.Text = @"c:\test";) Can someone shed some light? Have I provided enough information?

È stato utile?

Soluzione

does this work?

   tb_basefolder.DataBindings.Add("Text",cliView,"basefolder",  false, DataSourceUpdateMode.OnPropertyChanged);

why do you use static members for dataview and datarow?

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top