I took my time getting back to it.... as usual other
things overtake the issue, but have now successfully
tried, and am using, the above.
All - Thanks for your help!
Mike.
>-----Original Message-----
>Brad,
>It certainly would. As the saying goes, there is always
more than one way
>to skin a cat.
>I wrote the previous snippet in a hurry. Would not be
surprised if it
>could be optimized further :>)
>Patrick Cole
>Microsoft Developer Support
>This posting is provided "AS IS" with no warranties, and
confers no rights.
>You assume all risk for your use. ? 2002 Microsoft
Corporation. All rights
>reserved.
>--------------------
>| Reply-To: "Brad Quinn" <brad_qu...@yahoo.com>
>| From: "Brad Quinn" <brad_qu...@yahoo.com>
>| References: <2cea01c24471$6507abf0
$39ef2ecf@TKMSFTNGXA08>
><oV5ngcVRCHA.2644@cpmsftngxa06>
><48ed01c24838$43086fb0$35ef2ecf@TKMSFTNGXA11>
><CRr6jzFSCHA.2668@cpmsftngxa10>
>| Subject: Re: Can't get the value of a text box using
it's ID
>| Date: Tue, 20 Aug 2002 15:27:39 -0500
>| Lines: 166
>| X-Priority: 3
>| X-MSMail-Priority: Normal
>| X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
>| X-MimeOLE: Produced By Microsoft MimeOLE
V6.00.2600.0000
>| Message-ID: <#4knlfISCHA.1768@tkmsftngp13>
>| Newsgroups:
microsoft.public.dotnet.framework.aspnet.webcontrols
>| NNTP-Posting-Host: 206.50.253.82
>| Path: cpmsftngxa10!tkmsftngp01!tkmsftngp13
>| Xref: cpmsftngxa10
>microsoft.public.dotnet.framework.aspnet.webcontrols:4756
>| X-Tomcat-NG:
microsoft.public.dotnet.framework.aspnet.webcontrols
>|
>| Wouldn't it be easier to code;
>|
>| foreach(DataGridItem dgiTemp in dgTemp.Items)
>|
>| instead of;
>|
>| foreach(DataGridItem dgiTemp in dgTemp.Controls
[0].Controls)
>|
>| Then you could do away with the ItemType test.
Couldn't you?
>|
>| "Patrick C. Cole (MS)" <patc...@online.microsoft.com>
wrote in message
>| news:CRr6jzFSCHA.2668@cpmsftngxa10...
>| > Michael,
>| >
>| > I see no reason why you could not iternate through a
list of
>DataGridItems
>| > for controls created in an ItemTemplate.
EditItemTemplate is a
>different
>| > story. In fact, if you are not updating the
DataGrid via an
>| Update_Command
>| > event, I would think that enumerating the
DataGridItems would be the
>only
>| > solution.
>| >
>| > I did not see the other post you are referring to,
but here is a sample
>| > that will loop through the DataGrid, locate the
TextBox, and return the
>| > text of each TextBox.
>| >
>| > // Modify "DataGrid1" to locate your DataGrid control
>| > DataGrid dgTemp = ((DataGrid)this.FindControl
("DataGrid1"));
>| >
>| > // Loop through all DataGridItems in the DataGrid.
>| > foreach(DataGridItem dgiTemp in dgTemp.Controls
[0].Controls)
>| > {
>| > // Check for Item or AlternatingItem DataGridItems.
Most likely you
>| > // will not have TextBoxes in the Header or Footer
rows.
>| > if(dgiTemp.ItemType.ToString() == "Item" ||
dgiTemp.ItemType.ToString()
>| > == "AlternatingItem")
>| > {
>| > // "Test" is the ID of my TextBox.
>| > TextBox tbTemp = ((TextBox)(dgiTemp.FindControl
("Test")));
>| > // Simply get the value and return it to the screen.
>| > Response.Write(tbTemp.Text + "<br>");
>| > }
>| > }
>| >
>| > Patrick Cole
>| > Microsoft Developer Support
>| >
>| > This posting is provided "AS IS" with no warranties,
and confers no
>| rights.
>| > You assume all risk for your use. ? 2002 Microsoft
Corporation. All
>rights
>| > reserved.
>| > --------------------
>| > | Content-Class: urn:content-classes:message
>| > | From: "Michael Owen" <m...@mikeowen.co.uk>
>| > | Sender: "Michael Owen" <m...@mikeowen.co.uk>
>| > | References: <2cea01c24471$6507abf0
$39ef2ecf@TKMSFTNGXA08>
>| > <oV5ngcVRCHA.2644@cpmsftngxa06>
>| > | Subject: RE: Can't get the value of a text box
using it's ID
>| > | Date: Tue, 20 Aug 2002 03:56:39 -0700
>| > | Lines: 94
>| > | Message-ID: <48ed01c24838$43086fb0
$35ef2ecf@TKMSFTNGXA11>
>| > | MIME-Version: 1.0
>| > | Content-Type: text/plain;
>| > | charset="iso-8859-1"
>| > | Content-Transfer-Encoding: quoted-printable
>| > | X-Newsreader: Microsoft CDO for Windows 2000
>| > | X-MimeOLE: Produced By Microsoft MimeOLE
V5.50.4910.0300
>| > | Thread-Index: AcJIOEMIT+k7zDRYQUCOdkoSf0V0tQ==
>| > | Newsgroups:
microsoft.public.dotnet.framework.aspnet.webcontrols
>| > | NNTP-Posting-Host: TKMSFTNGXA11 10.201.226.39
>| > | Path: cpmsftngxa10!tkmsftngp01!cpmsftngxa07
>| > | Xref: cpmsftngxa10
>| >
microsoft.public.dotnet.framework.aspnet.webcontrols:4737
>| > | X-Tomcat-NG:
microsoft.public.dotnet.framework.aspnet.webcontrols
>| > |
>| > | Patrick,
>| > | I am trying to get the value on a button onClick
event,
>| > | i.e. in this case 'btnPlaceOrder_Click'.
>| > | I don't think the earlier suggestion by Mathew
curry
>| > | would work - There is no way to iterate through
each text
>| > | box automatically created by the Grid/Template
control?
>| > | To expand slightly on what I am trying to do - I am
>| > | trying to iterate though all of the order quantity
boxes
>| > | to see which items have been ordered. I will then
go on
>| > | to create the order for the items in a DB.
>| > | Thanks, Mike.
>| > | >-----Original Message-----
>| > | >Michael,
>| > | >
>| > | >Where are you attempting to get the value of the
>| > | textbox? In what event on
>| > | >PostBack?
>| > | >
>| > | >Patrick Cole
>| > | >Microsoft Developer Support
>| > | >
>| > | >This posting is provided "AS IS" with no
warranties, and
>| > | confers no rights.
>| > | >You assume all risk for your use. ? 2002 Microsoft
>| > | Corporation. All rights
>| > | >reserved.
>| > | >--------------------
>| > | >| Content-Class: urn:content-classes:message
>| > | >| From: "Michael Owen" <m...@mikeowen.co.uk>
>| > | >| Sender: "Michael Owen" <m...@mikeowen.co.uk>
>| > | >| Subject: Can't get the value of a text box
using it's
>| > | ID
>| > | >| Date: Thu, 15 Aug 2002 08:35:33 -0700
>| > | >| Lines: 25
>| > | >| Message-ID: <2cea01c24471$6507abf0
>| > | $39ef2ecf@TKMSFTNGXA08>
>| > | >| MIME-Version: 1.0
>| > | >| Content-Type: text/plain;
>| > | >| charset="iso-8859-1"
>| > | >| Content-Transfer-Encoding: 7bit
>| > | >| X-Newsreader: Microsoft CDO for Windows 2000
>| > | >| X-MimeOLE: Produced By Microsoft MimeOLE
>| > | V5.50.4910.0300
>| > | >| Thread-Index: AcJEcWUHr7LHrgV+QVSQHd1LqqKGJQ==
>| > | >| Newsgroups:
>| > |
microsoft.public.dotnet.framework.aspnet.webcontrols
>| > | >| Path: cpmsftngxa06
>| > | >| Xref: cpmsftngxa06
>| > |
>microsoft.public.dotnet.framework.aspnet.webcontrols:4642
>| > | >| NNTP-Posting-Host: TKMSFTNGXA08 10.201.226.36
>| > | >| X-Tomcat-NG:
>| > |
microsoft.public.dotnet.framework.aspnet.webcontrols
>| > | >|
>| > | >| What am I doing wrong?
>| > | >|
>| > | >| I have a text box within template in a DataGrid
>| > | control
>| > | >| with the ID of grdPackages__ctl3_txtOrderQty'.
Most
>| > | of
>| > | >| the ID has been generated automatically by
asp.Net.
>| > | The
>| > | >| name I gave it was 'txtOrderQty'.
>| > | >|
>| > | >| If I try to get the value of this text box once
the
>| > | form
>| > | >| has been submitted, using:
>| > | >|
>| > | >| Request.Form
("grdPackages__ctl4_txtOrderQty")
>| > | >|
>| > | >| The value is a zero length string, yet I can
see the
>| > | >| value is in fact a zero, i.e. "0".
>| > | >|
>| > | >| Interestingly if use Request.Form(2), the
correct
>| > | value
>| > | >| is returned.
>| > | >|
>| > | >| Why is the correct value not returned?
>| > | >|
>| > | >| Is there an easier way of getting the values
returned
>| > | >| from text boxes within a template on a DataGrid
>| > | control?
>| > | >|
>| > | >|
>| > | >| Many thanks, Mike.
>| > | >|
>| > | >
>| > | >.
>| > | >
>| > |
>| >
>|
>|
>|
>.