CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2002
    Posts
    788

    Any body out there know why this doen;'t work!??

    I want to bind a button text to a field in my datatable in my dataset. I have used the Studio designer to create a dataTable called MyDataTable, with 2 column, Id is the primary key and Reading is the data i want to bind to.

    I need a solution in particular.

    Code:
      private void Form1_Load(object sender, EventArgs e)
            {
                    
    DataSet2.MyDataTableDataTable dt2 = dataSet2.MyDataTable;
    
                for (int z = 0; z < 5; z++)
                {
                    DataSet2.MyDataTableRow dr2 = dt2.NewMyDataTableRow();
                    dr2.Id = z;
                    dr2.Reading = z;
                    dt2.Rows.Add(dr2);
                }
               
    //i want to bind to row2 in my table.
    button2.DataBindings.Add(new Binding("Text", dt2[2], "Reading", false, DataSourceUpdateMode.OnPropertyChanged));
       
            }
    
      private void button3_Click_1(object sender, EventArgs e)
            {
    
                DataSet2.MyDataTableDataTable dt2 = dataSet2.MyDataTable;
                DataSet2.MyDataTableRow dr = dt2.FindById(2);
                dr.Reading = 150;
                dataSet2.AcceptChanges();
    
    }
    The text on button1 only shows 2. No matter what i did, it doesn;t change to show 150 as it supposed to when i click button3., as in handled in function event button3_Click_1.

  2. #2
    Join Date
    Mar 2008
    Location
    IRAN
    Posts
    811

    Re: Any body out there know why this doen;'t work!??

    use:
    button2.Refresh()
    Please rate my post if it was helpful for you.
    Java, C#, C++, PHP, ASP.NET
    SQL Server, MySQL
    DirectX
    MATH
    Touraj Ebrahimi
    [toraj_e] [at] [yahoo] [dot] [com]

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

Featured