Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 17th, 2007, 02:54 AM
Authorized User
Join Date: May 2007
Location: Frankfurt, Germany, Germany.
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to DarkForce
Default Change Text of Textbox inside Template


I have a Detailsview and a Textbox inside a Templatefield.
I try to access the Textbox in the %%%.cs Data file but i cannot.
Should look like

TextBox1.Text = "Hallo";

So long
Reply With Quote
  #2 (permalink)  
Old June 17th, 2007, 03:21 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts

Hi there,

No, you can't access these controls directly. The DetailsView is a container control that contains these individual controls. Since you can potentially have more than one DetailsView on a page, the DetailsView must ensure that each TextBox and other controls have a unique name.

Depending on when and where you use this code, you can try this:

TextBox myTextBox = (TextBox) DetailsView1.FindControl("TextBox1")
myTextBox.Text = "Hallo";

This code "finds" the TextBox inside the DetailsView and then sets its text.

Hope this helps,


Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #3 (permalink)  
Old June 17th, 2007, 12:49 PM
Authorized User
Join Date: May 2007
Location: Frankfurt, Germany, Germany.
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to DarkForce

Thank you Imar,this helped a lot

So long
Reply With Quote
  #4 (permalink)  
Old September 14th, 2012, 07:11 AM
Registered User
Points: 13, Level: 1
Points: 13, Level: 1 Points: 13, Level: 1 Points: 13, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Sep 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

Using JQuery/JavaScript, is it possible to access properties of controls which reside inside EditItemTemplate?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head><link href="StyleSheet.css" rel="stylesheet" type="text/css" />
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
    <script src="jquery.js" type="text/javascript"></script>
    <style type ="text/css">

    <form method="post" action="Default.aspx" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="3Pmn9Z3SnssjpgmTk85Nr2jhTsqd5NHedGdkMUfV+2dPaqpHt7qp/2AWX9qOhiwAFCM9RHQI5rENTpeESwRy0ZZeQVBfClrV5iFUhbf7XplozcfU8eKGVqL1sFReaPgLR/lhLIWzA8NwfBS1ebYMSgbpdja4qj0SwaXKUAsibz3c2KENEyt08DUX5HwAazWpKdOm9jFalKOg+o0ui/NgbDZSHQ9SHJpIyQL7yahDzaJk0Jdd2phbtPcAp48UwabuL6/T2l2uo56gqvTyBoE6S9aF1hDQa7IEAFskaQtw4HqhvPz/66aaN/1Hj6K967JedxNCZCbNIy97gqHLD3C4HznIJBqxcp2gfBfkyA7CwO4=" />

<script type="text/javascript">
var theForm = document.forms['form1'];
if (!theForm) {
    theForm = document.form1;
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;

<div class="aspNetHidden">

	<input type="hidden" name="__VIEWSTATEENCRYPTED" id="__VIEWSTATEENCRYPTED" value="" />
	<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="MEy46W8V6LdjyyEkxaS8Q3uielIKJ8u0QGKH77tD9QAVNTPLEp4rSVZbPSy4z9DPsJn/KADTdCOJVTfLBPoYQghZFTsikn1INk1acz34miDY09vW4qF+EQtlZKF44xIpea0TTMKkXGzADHlQAht/oA337ZeTL6m2WOhnu4CXwgk=" />
	<table cellspacing="0" rules="all" border="1" id="DetailsView1" style="height:50px;width:125px;border-collapse:collapse;">
                        <span id="DetailsView1_Label2">Please type row number:</span>
                        <br />
                        <input name="DetailsView1$txtRowNumber" type="text" id="DetailsView1_txtRowNumber" csCssClass="clsFind" />
                        <input name="DetailsView1$TextBox1" type="text" value="B         " id="DetailsView1_TextBox1" />
			<td colspan="2"><a href="javascript:__doPostBack('DetailsView1$ctl01','')">Update</a>&nbsp;<a href="javascript:__doPostBack('DetailsView1','Cancel$0')">Cancel</a></td>
			<td>Delete</td><td align="left" style="width:20%;">
                            <a id="DetailsView1_lnkDelete" class="clsFind" href="javascript:__doPostBack('DetailsView1$lnkDelete','')">Delete</a>
                            <a id="DetailsView1_lnkShow" class="clsFind" href="javascript:__doPostBack('DetailsView1$lnkShow','')">show</a>
			<td colspan="2"><table>
					<td><span>1</span></td><td><a href="javascript:__doPostBack('DetailsView1','Page$2')">2</a></td>
        <br />
        <input type="submit" name="btnShowControl" value="Show Delete Button" onclick="return ShowControl();" id="btnShowControl" />
        <input type="submit" name="btnHideControl" value="Hide Delete Button" onclick="return HideControl();" id="btnHideControl" />

Specifically i am trying to access txtRowNumber.
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Global parameter calculation inside template Volder XSLT 8 June 20th, 2008 08:10 AM
value-of inside template match RoeZ XSLT 5 April 17th, 2008 12:09 PM
get value of textbox inside datagrid khaink ASP.NET 1.0 and 1.1 Basics 9 October 2nd, 2007 10:05 AM
TextBox inside GridView michurin ASP.NET 2.0 Basics 2 January 13th, 2007 12:51 PM
How to change text in textbox from sub in module jano59 Beginning VB 6 1 September 6th, 2005 12:58 PM

All times are GMT -4. The time now is 10:11 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.