-
February 9th, 2009, 02:23 AM
#1
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.
-
February 9th, 2009, 12:12 PM
#2
Re: Any body out there know why this doen;'t work!??
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|