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 / Languages / C# / August 2007

Tip: Looking for answers? Try searching our database.

DetailsView & TextBox (C#)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
G - 28 Aug 2007 14:39 GMT
Hello,

I have a detailsview on page, called DetailsView1.  I also have an
ItemTemplate TextBox called PaymentStatus.

I want to from CODE BEHIND update the text of PaymentStatus but I am unable
to reference this object, and I have tried for hours to use FindControl to
no real progress.

Anyone able to help?

Regards,

Gary.
Jani Järvinen [MVP] - 28 Aug 2007 17:19 GMT
Hello Gary,

> I want to from CODE BEHIND update the text of PaymentStatus but I am
> unable to reference this object, and I have tried for hours to use
> FindControl to no real progress.

I suggest that you use the Rows property (whics is a collection) to access
the rows (and controls thereafter) in your DetailsView component instead of
using FindControl. FindControl should work, but the problem is that many
component names have dynamically created names, and might not be what you
expect.

Instead, try using the Rows property with an index. For example, you could
use code similar to this:

----------
DetailsViewRow row = MyDetailsView.Rows[2]; // third row
TextBox myTextBox = (TextBox)row.Cells[1].Controls[0]; // text box in second
cell
myTextBox.Text = ...
----------

Hope this helps!

Signature

Regards,

Mr. Jani Järvinen
C# MVP
Helsinki, Finland
janij@removethis.dystopia.fi
http://www.saunalahti.fi/janij/


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.