Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / July 2004

Tip: Looking for answers? Try searching our database.

Binding to DataView.Count Bug?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JorgenD - 07 Jul 2004 12:13 GMT
Hi.

When binding to the Count property of a DataView, the bound control is not updated when applying a rowfilter to the DataView.

Sample code:

dt = new DataTable();
dt.Columns.Add("Val",typeof(int));
DataRow row;
           
row = dt.NewRow();
row["Val"]=1;
dt.Rows.Add(row);

row = dt.NewRow();
row["Val"]=2;
dt.Rows.Add(row);

row = dt.NewRow();
row["Val"]=2;
dt.Rows.Add(row);
           
textBox1.DataBindings.Add("Text",dt.DefaultView.Count,"");

****** the TextBox shows "3"

dt.DefaultView.RowFilter="Val=1";

****** the TextBox STILL shows "3"

Is this a bug or am I doing something wrong?

Surely I can do this without databinding, but I'm not looking for alternative solutions!
Jay B. Harlow [MVP - Outlook] - 07 Jul 2004 15:40 GMT
Jorgen,
My understanding is:

DataView does not have a CountChanged event, for the data bound TextBox to
update itself when DataView.Count property changes, the PropertyManager
listens for the DataView.CountChanged event, and update the TextBox
appropriately, well seeing as there is no CountChanged event, nothing
happens...

The above is assuming you bound to the Count property, not the value of
Count itself...

   textBox1.DataBindings.Add("Text",dt.DefaultView,"Count");

> textBox1.DataBindings.Add("Text",dt.DefaultView.Count,"");
Also you are binding to a value type, it will be boxed, for ever breaking
the tie to the DataView itself...

Hope this helps
Jay

> Hi.
>
[quoted text clipped - 29 lines]
>
> Surely I can do this without databinding, but I'm not looking for alternative solutions!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.