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 / March 2005

Tip: Looking for answers? Try searching our database.

Unable to bind untyped dataset to textboxes, anyone done this?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Håkon Eide - 15 Mar 2005 11:35 GMT
I have a dataTable with only one unique record and want to bind this to
a couple of textboxes in a form, so that when a user changes a value,
it's eventually reflected back to the database.

The dataset I use is 'untyped' - so I'm not able to do a typed databind,
and this is causing me great troubles...  Does anyone know how to do this?

The code:

tbTagno.DataBindings.Add("Text",dtTagDetails.Rows[0].ItemArray[0].ToString(),null);

works in so far as displaying the read database value from the dataTable
dtTagDetails, but since the third parameter is null, nothing is sent
back from the textbox naturally. And I can't find any way to set ut the
third parameter correctly!

tbTagDesc.DataBindings.Add("Text",dtTagDetails.Rows[0].ItemArray[2].ToString(),"dtTagDetails.Columns[2].ColumnName");

does not compile of course.

(As a workaround, I've tried manuall copying values back and forth on
load and save, the code:

tbTagno.Text        = dtTagDetails.Rows[0].ItemArray[0].ToString();

works, i.e. the form field is updated with the value from the database
row, but when trying to do a:

dtTagDetails.Rows[0].ItemArray[2] = tbTagDesc.Text;   

or a:

daTagDetails.ds.Tables[0].Rows[0].ItemArray[2] = tbTagDesc.Text;

none of the dataTable or dataAdapter arrays are changed... they seem to
be locked with their original database value....

Anyone got any ideas on untyped datasets?  Am I missing something vital
in using these? Do I need to use currencyManager even though I only have
one row in my dataTable?

Regards,
-Haakon-
the
Alexander Shirshov - 20 Mar 2005 16:51 GMT
Try this:

tbTagDesc.DataBindings.Add("Text", dtTagDetails, "ColumnName");

HTH,
Alexander

>I have a dataTable with only one unique record and want to bind this to a
>couple of textboxes in a form, so that when a user changes a value, it's
[quoted text clipped - 39 lines]
> -Haakon-
> the
Håkon Eide - 21 Mar 2005 10:30 GMT
Tried that, doesn't work.  However, this works:

tbTagDesc.DataBindings.Add("Text", dtTagDetails,
dtTagDetails.Columns[2].ColumnName);           

..and when I then include a

this.BindingContext[dtTagDetails].EndCurrentEdit();

when user click's "Save" - the data is updated and everything works!
Maybe this can help others struggling with untyped datasets....

Regards,
-Haakon-

> Try this:
>
> tbTagDesc.DataBindings.Add("Text", dtTagDetails, "ColumnName");
>
> HTH,
> Alexander
Stanley - 21 Mar 2005 14:08 GMT
Change it to:
tbTagDesc.DataBindings.Add(New
Binding("Text",dtTagDetails,Columns[2].ColumnName))

This is assuming that dtTagDetails is a datatable.

-Stanley

> Tried that, doesn't work.  However, this works:
>
[quoted text clipped - 17 lines]
>> HTH,
>> Alexander

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.