Thanks for your followup.
Glad that you've got it working.
Have a good day!
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| Thread-Topic: Call client script to update an item in a data grid
| thread-index: AcYV7ife9MRNssIKRDOhSulEpS82aQ==
| X-WBNR-Posting-Host: 70.118.231.121
| From: =?Utf-8?B?TGVoclNK?= <lehr524@noemail.nospam>
| References: <FEBA6FEE-917A-4604-A780-45DFC22CBA2E@microsoft.com>
<Of12ioqDGHA.3828@TK2MSFTNGP14.phx.gbl>
<fJbEvFBEGHA.3764@TK2MSFTNGXA02.phx.gbl>
<D33BC714-6049-4433-9E09-1A50B0AA8666@microsoft.com>
<GGcg48NEGHA.1888@TK2MSFTNGXA02.phx.gbl>
<394EAC90-EDDA-49C3-9F2C-12816299A9F2@microsoft.com>
<dAMVNTPFGHA.3680@TK2MSFTNGXA02.phx.gbl>
| Subject: Re: Call client script to update an item in a data grid
| Date: Tue, 10 Jan 2006 06:00:04 -0800
| Lines: 266
| Message-ID: <6D119A35-8527-4A9F-B0B4-C7A6CE55DD4C@microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet.datagridcontrol:15040
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
|
| I finally realized what I was doing wrong. I got it to work with the
| ItemCreated event. My problem was that the textbox only exists when the
| current mode is edit. I wasn't checking for this and was trying to add
the
| attribute when in readonly mode. So I got an error. It's working fine
now.
| Thanks.
| --
| LehrSJ
|
|
[quoted text, click to view] | "Steven Cheng[MSFT]" wrote:
|
| > Thanks for your response LehrSJ,
| >
| > Surely the TextBox's PreRender event won't contains the same event
Argument
| > like DataGird's ItemDataBound or itemCreated, however, when we just
need to
| > add some attributes which only related to the Textbox's own
value(number
| > formatting or range validation scripts...), PreRender will be a good
event
| > since it is only associated with the textbox we want to hook....
Also,
| > PreRendder event is the last event we can use to change controls'
states
| > before rendering out(so the page's control structure should have been
| > construted well at that time...)
| >
| > And if you want your registered script also depend on some info on the
| > DataGrid's bound data item or other cells' value, I think we have to
use
| > ItemDataBound event ....
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure!
www.microsoft.com/security | > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| >
| >
| > --------------------
| > | Thread-Topic: Call client script to update an item in a data grid
| > | thread-index: AcYTlFRiiNBKU6J8SzCuVoP2xTc+vQ==
| > | X-WBNR-Posting-Host: 70.118.231.121
| > | From: =?Utf-8?B?TGVoclNK?= <lehr524@noemail.nospam>
| > | References: <FEBA6FEE-917A-4604-A780-45DFC22CBA2E@microsoft.com>
| > <Of12ioqDGHA.3828@TK2MSFTNGP14.phx.gbl>
| > <fJbEvFBEGHA.3764@TK2MSFTNGXA02.phx.gbl>
| > <D33BC714-6049-4433-9E09-1A50B0AA8666@microsoft.com>
| > <GGcg48NEGHA.1888@TK2MSFTNGXA02.phx.gbl>
| > | Subject: Re: Call client script to update an item in a data grid
| > | Date: Sat, 7 Jan 2006 06:12:02 -0800
| > | Lines: 173
| > | Message-ID: <394EAC90-EDDA-49C3-9F2C-12816299A9F2@microsoft.com>
| > | MIME-Version: 1.0
| > | Content-Type: text/plain;
| > | charset="Utf-8"
| > | Content-Transfer-Encoding: 7bit
| > | X-Newsreader: Microsoft CDO for Windows 2000
| > | Content-Class: urn:content-classes:message
| > | Importance: normal
| > | Priority: normal
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| > | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
| > | Xref: TK2MSFTNGXA02.phx.gbl
| > microsoft.public.dotnet.framework.aspnet.datagridcontrol:15020
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| > |
| > | Thanks for the information but I don't see what to do in the
PreRender
| > event
| > | to add the attribute to the textbox for the client script to call.
In
| > the
| > | edit template field the textbox name is EmpName. So my PreRender
event
| > looks
| > | like:
| > |
| > | Protected Sub EmpName_PreRender(ByVal sender As Object, ByVal e As
| > | System.EventArgs)
| > |
| > | But there is no "e.item" option to refer to the item like the example
you
| > | had for the datagrid, DataGridItemEventArgs.
| > | --
| > | LehrSJ
| > |
| > |
[quoted text, click to view] | > | "Steven Cheng[MSFT]" wrote:
| > |
| > | > Of course GridView, DetailsView and most other template databound
| > controls
| > | > can utilize such means.... Also, there is another method for
| > injecting
| > | > clientside script for such inner controls:
| > | >
| > | > We can declare a "PreRender" event handler for those controls (a
| > | > TextBox....), e.g:
| > | >
| > | > ==============
| > | > <EditItemTemplate>
| > | > id:
| > | > <asp:Label ID="idLabel1" runat="server" Text='<%#
| > | > Eval("id") %>'></asp:Label><br />
| > | > name:
| > | > <asp:TextBox ID="nameTextBox" runat="server"
Text='<%#
| > | > Bind("name") %>' OnPreRender="TextBox_OnPreRender">
| > | > </asp:TextBox><br />
| > | > ================
| > | >
| > | > "TextBox_OnPreRender" is a non-private method defined in the Page's
| > | > codebehind class, and we put the script registering code in that
| > | > method......
| > | >
| > | > Using this means can avoid intercepting the DataBound control's
| > ItemCreated
| > | > or ItemDataBound event, only concencrate on the inner control we
care
| > | > about....
| > | >
| > | > Hope also helps. Thanks,
| > | >
| > | > Steven Cheng
| > | > Microsoft Online Support
| > | >
| > | > Get Secure!
www.microsoft.com/security | > | > (This posting is provided "AS IS", with no warranties, and confers
no
| > | > rights.)
| > | >
| > | >
| > | >
| > | > --------------------
| > | > | Thread-Topic: Call client script to update an item in a data grid
| > | > | thread-index: AcYQdR5oMm/Eg1pxS16acJmte72Btw==
| > | > | X-WBNR-Posting-Host: 70.118.231.121
| > | > | From: =?Utf-8?B?TGVoclNK?= <lehr524@noemail.nospam>