Call client script to update an item in a data grid

Discussion in 'ASP .Net Datagrid Control' started by LehrSJ, Dec 30, 2005.

  1. LehrSJ

    LehrSJ Guest

    Is there a way to run client script function or procedure to update data in a
    data grid? Say I have a textbox in the datagrid. The user enters some data.
    After exiting the textbox I'd like a client script to change the new value to
    all upper case or if it's a date format it a certain way.

    thanks
    --
    LehrSJ
     
    LehrSJ, Dec 30, 2005
    #1
    1. Advertising

  2. Sure, you just need to setup client-side events. One way is to handle the
    grid's ItemDataBound event. In the event you get access to the item (row)
    elements and use their Attributes collection for adding client-side event
    handlers.

    Eliyahu

    "LehrSJ" <> wrote in message
    news:...
    > Is there a way to run client script function or procedure to update data
    > in a
    > data grid? Say I have a textbox in the datagrid. The user enters some
    > data.
    > After exiting the textbox I'd like a client script to change the new value
    > to
    > all upper case or if it's a date format it a certain way.
    >
    > thanks
    > --
    > LehrSJ
     
    Eliyahu Goldin, Jan 1, 2006
    #2
    1. Advertising

  3. Hi LehrSJ,

    As Eliyahu has mentioned, we can use the DataGrid's ItemDataBound or
    ItemCreated event to add the clientside script handler for the certain
    controls in the DataGrid Column.... e.g:

    Sub DataGrid_ItemCreated(Sender As Object, e As DataGridItemEventArgs)
    Select Case e.Item.ItemType
    Case ListItemType.Item, ListItemType.AlternatingItem,
    ListItemType.EditItem
    Dim myDeleteButton As Button
    myDeleteButton = e.Item.FindControl("btnDelete")
    myDeleteButton.Attributes.Add("onclick",_
    "return confirm('Are you sure you want to delete this company?');")

    End Select
    End Sub

    the above code programmatically add a confirm script for a button in a
    datagrid template column....

    Also, you can use predefined script functions in aspx page also......

    Hope helps.

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
    --------------------
    | From: "Eliyahu Goldin" <>
    | References: <>
    | Subject: Re: Call client script to update an item in a data grid
    | Date: Sun, 1 Jan 2006 10:04:22 +0200
    | Lines: 22
    | X-Priority: 3
    | X-MSMail-Priority: Normal
    | X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
    | X-RFC2646: Format=Flowed; Original
    | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
    | Message-ID: <>
    | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
    | NNTP-Posting-Host: 212.143.94.3
    | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
    | Xref: TK2MSFTNGXA02.phx.gbl
    microsoft.public.dotnet.framework.aspnet.datagridcontrol:14995
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
    |
    | Sure, you just need to setup client-side events. One way is to handle the
    | grid's ItemDataBound event. In the event you get access to the item (row)
    | elements and use their Attributes collection for adding client-side event
    | handlers.
    |
    | Eliyahu
    |
    | "LehrSJ" <> wrote in message
    | news:...
    | > Is there a way to run client script function or procedure to update
    data
    | > in a
    | > data grid? Say I have a textbox in the datagrid. The user enters some
    | > data.
    | > After exiting the textbox I'd like a client script to change the new
    value
    | > to
    | > all upper case or if it's a date format it a certain way.
    | >
    | > thanks
    | > --
    | > LehrSJ
    |
    |
    |
     
    Steven Cheng[MSFT], Jan 3, 2006
    #3
  4. LehrSJ

    LehrSJ Guest

    Thanks. Is it possible to do this with a GridView or DetailsView?
    --
    LehrSJ


    "Steven Cheng[MSFT]" wrote:

    > Hi LehrSJ,
    >
    > As Eliyahu has mentioned, we can use the DataGrid's ItemDataBound or
    > ItemCreated event to add the clientside script handler for the certain
    > controls in the DataGrid Column.... e.g:
    >
    > Sub DataGrid_ItemCreated(Sender As Object, e As DataGridItemEventArgs)
    > Select Case e.Item.ItemType
    > Case ListItemType.Item, ListItemType.AlternatingItem,
    > ListItemType.EditItem
    > Dim myDeleteButton As Button
    > myDeleteButton = e.Item.FindControl("btnDelete")
    > myDeleteButton.Attributes.Add("onclick",_
    > "return confirm('Are you sure you want to delete this company?');")
    >
    > End Select
    > End Sub
    >
    > the above code programmatically add a confirm script for a button in a
    > datagrid template column....
    >
    > Also, you can use predefined script functions in aspx page also......
    >
    > Hope helps.
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    > --------------------
    > | From: "Eliyahu Goldin" <>
    > | References: <>
    > | Subject: Re: Call client script to update an item in a data grid
    > | Date: Sun, 1 Jan 2006 10:04:22 +0200
    > | Lines: 22
    > | X-Priority: 3
    > | X-MSMail-Priority: Normal
    > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
    > | X-RFC2646: Format=Flowed; Original
    > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
    > | Message-ID: <>
    > | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
    > | NNTP-Posting-Host: 212.143.94.3
    > | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
    > | Xref: TK2MSFTNGXA02.phx.gbl
    > microsoft.public.dotnet.framework.aspnet.datagridcontrol:14995
    > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
    > |
    > | Sure, you just need to setup client-side events. One way is to handle the
    > | grid's ItemDataBound event. In the event you get access to the item (row)
    > | elements and use their Attributes collection for adding client-side event
    > | handlers.
    > |
    > | Eliyahu
    > |
    > | "LehrSJ" <> wrote in message
    > | news:...
    > | > Is there a way to run client script function or procedure to update
    > data
    > | > in a
    > | > data grid? Say I have a textbox in the datagrid. The user enters some
    > | > data.
    > | > After exiting the textbox I'd like a client script to change the new
    > value
    > | > to
    > | > all upper case or if it's a date format it a certain way.
    > | >
    > | > thanks
    > | > --
    > | > LehrSJ
    > |
    > |
    > |
    >
    >
     
    LehrSJ, Jan 3, 2006
    #4
  5. 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?= <>
    | References: <>
    <>
    <>
    | Subject: Re: Call client script to update an item in a data grid
    | Date: Tue, 3 Jan 2006 06:51:03 -0800
    | Lines: 84
    | Message-ID: <>
    | 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!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
    | Xref: TK2MSFTNGXA02.phx.gbl
    microsoft.public.dotnet.framework.aspnet.datagridcontrol:15004
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
    |
    | Thanks. Is it possible to do this with a GridView or DetailsView?
    | --
    | LehrSJ
    |
    |
    | "Steven Cheng[MSFT]" wrote:
    |
    | > Hi LehrSJ,
    | >
    | > As Eliyahu has mentioned, we can use the DataGrid's ItemDataBound or
    | > ItemCreated event to add the clientside script handler for the certain
    | > controls in the DataGrid Column.... e.g:
    | >
    | > Sub DataGrid_ItemCreated(Sender As Object, e As DataGridItemEventArgs)
    | > Select Case e.Item.ItemType
    | > Case ListItemType.Item, ListItemType.AlternatingItem,
    | > ListItemType.EditItem
    | > Dim myDeleteButton As Button
    | > myDeleteButton = e.Item.FindControl("btnDelete")
    | > myDeleteButton.Attributes.Add("onclick",_
    | > "return confirm('Are you sure you want to delete this company?');")
    | >
    | > End Select
    | > End Sub
    | >
    | > the above code programmatically add a confirm script for a button in a
    | > datagrid template column....
    | >
    | > Also, you can use predefined script functions in aspx page also......
    | >
    | > Hope helps.
    | >
    | > Steven Cheng
    | > Microsoft Online Support
    | >
    | > Get Secure! www.microsoft.com/security
    | > (This posting is provided "AS IS", with no warranties, and confers no
    | > rights.)
    | > --------------------
    | > | From: "Eliyahu Goldin" <>
    | > | References: <>
    | > | Subject: Re: Call client script to update an item in a data grid
    | > | Date: Sun, 1 Jan 2006 10:04:22 +0200
    | > | Lines: 22
    | > | X-Priority: 3
    | > | X-MSMail-Priority: Normal
    | > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
    | > | X-RFC2646: Format=Flowed; Original
    | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
    | > | Message-ID: <>
    | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
    | > | NNTP-Posting-Host: 212.143.94.3
    | > | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
    | > | Xref: TK2MSFTNGXA02.phx.gbl
    | > microsoft.public.dotnet.framework.aspnet.datagridcontrol:14995
    | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
    | > |
    | > | Sure, you just need to setup client-side events. One way is to handle
    the
    | > | grid's ItemDataBound event. In the event you get access to the item
    (row)
    | > | elements and use their Attributes collection for adding client-side
    event
    | > | handlers.
    | > |
    | > | Eliyahu
    | > |
    | > | "LehrSJ" <> wrote in message
    | > | news:...
    | > | > Is there a way to run client script function or procedure to update
    | > data
    | > | > in a
    | > | > data grid? Say I have a textbox in the datagrid. The user enters
    some
    | > | > data.
    | > | > After exiting the textbox I'd like a client script to change the
    new
    | > value
    | > | > to
    | > | > all upper case or if it's a date format it a certain way.
    | > | >
    | > | > thanks
    | > | > --
    | > | > LehrSJ
    | > |
    | > |
    | > |
    | >
    | >
    |
     
    Steven Cheng[MSFT], Jan 4, 2006
    #5
  6. LehrSJ

    LehrSJ Guest

    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


    "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?= <>
    > | References: <>
    > <>
    > <>
    > | Subject: Re: Call client script to update an item in a data grid
    > | Date: Tue, 3 Jan 2006 06:51:03 -0800
    > | Lines: 84
    > | Message-ID: <>
    > | 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!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
    > | Xref: TK2MSFTNGXA02.phx.gbl
    > microsoft.public.dotnet.framework.aspnet.datagridcontrol:15004
    > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
    > |
    > | Thanks. Is it possible to do this with a GridView or DetailsView?
    > | --
    > | LehrSJ
    > |
    > |
    > | "Steven Cheng[MSFT]" wrote:
    > |
    > | > Hi LehrSJ,
    > | >
    > | > As Eliyahu has mentioned, we can use the DataGrid's ItemDataBound or
    > | > ItemCreated event to add the clientside script handler for the certain
    > | > controls in the DataGrid Column.... e.g:
    > | >
    > | > Sub DataGrid_ItemCreated(Sender As Object, e As DataGridItemEventArgs)
    > | > Select Case e.Item.ItemType
    > | > Case ListItemType.Item, ListItemType.AlternatingItem,
    > | > ListItemType.EditItem
    > | > Dim myDeleteButton As Button
    > | > myDeleteButton = e.Item.FindControl("btnDelete")
    > | > myDeleteButton.Attributes.Add("onclick",_
    > | > "return confirm('Are you sure you want to delete this company?');")
    > | >
    > | > End Select
    > | > End Sub
    > | >
    > | > the above code programmatically add a confirm script for a button in a
    > | > datagrid template column....
    > | >
    > | > Also, you can use predefined script functions in aspx page also......
    > | >
    > | > Hope helps.
    > | >
    > | > Steven Cheng
    > | > Microsoft Online Support
    > | >
    > | > Get Secure! www.microsoft.com/security
    > | > (This posting is provided "AS IS", with no warranties, and confers no
    > | > rights.)
    > | > --------------------
    > | > | From: "Eliyahu Goldin" <>
    > | > | References: <>
    > | > | Subject: Re: Call client script to update an item in a data grid
    > | > | Date: Sun, 1 Jan 2006 10:04:22 +0200
    > | > | Lines: 22
    > | > | X-Priority: 3
    > | > | X-MSMail-Priority: Normal
    > | > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
    > | > | X-RFC2646: Format=Flowed; Original
    > | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
    > | > | Message-ID: <>
    > | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
    > | > | NNTP-Posting-Host: 212.143.94.3
    > | > | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
    > | > | Xref: TK2MSFTNGXA02.phx.gbl
    > | > microsoft.public.dotnet.framework.aspnet.datagridcontrol:14995
    > | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
    > | > |
    > | > | Sure, you just need to setup client-side events. One way is to handle
    > the
    > | > | grid's ItemDataBound event. In the event you get access to the item
    > (row)
    > | > | elements and use their Attributes collection for adding client-side
    > event
    > | > | handlers.
    > | > |
    > | > | Eliyahu
    > | > |
    > | > | "LehrSJ" <> wrote in message
    > | > | news:...
    > | > | > Is there a way to run client script function or procedure to update
    > | > data
    > | > | > in a
    > | > | > data grid? Say I have a textbox in the datagrid. The user enters
    > some
    > | > | > data.
    > | > | > After exiting the textbox I'd like a client script to change the
    > new
    > | > value
    > | > | > to
    > | > | > all upper case or if it's a date format it a certain way.
    > | > | >
    > | > | > thanks
    > | > | > --
    > | > | > LehrSJ
    > | > |
    > | > |
    > | > |
    > | >
    > | >
    > |
    >
    >
     
    LehrSJ, Jan 7, 2006
    #6
  7. 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?= <>
    | References: <>
    <>
    <>
    <>
    <>
    | 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: <>
    | 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
    |
    |
    | "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?= <>
    | > | References: <>
    | > <>
    | > <>
    | > | Subject: Re: Call client script to update an item in a data grid
    | > | Date: Tue, 3 Jan 2006 06:51:03 -0800
    | > | Lines: 84
    | > | Message-ID: <>
    | > | 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!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
    | > | Xref: TK2MSFTNGXA02.phx.gbl
    | > microsoft.public.dotnet.framework.aspnet.datagridcontrol:15004
    | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
    | > |
    | > | Thanks. Is it possible to do this with a GridView or DetailsView?
    | > | --
    | > | LehrSJ
    | > |
    | > |
    | > | "Steven Cheng[MSFT]" wrote:
    | > |
    | > | > Hi LehrSJ,
    | > | >
    | > | > As Eliyahu has mentioned, we can use the DataGrid's ItemDataBound
    or
    | > | > ItemCreated event to add the clientside script handler for the
    certain
    | > | > controls in the DataGrid Column.... e.g:
    | > | >
    | > | > Sub DataGrid_ItemCreated(Sender As Object, e As
    DataGridItemEventArgs)
    | > | > Select Case e.Item.ItemType
    | > | > Case ListItemType.Item, ListItemType.AlternatingItem,
    | > | > ListItemType.EditItem
    | > | > Dim myDeleteButton As Button
    | > | > myDeleteButton = e.Item.FindControl("btnDelete")
    | > | > myDeleteButton.Attributes.Add("onclick",_
    | > | > "return confirm('Are you sure you want to delete this
    company?');")
    | > | >
    | > | > End Select
    | > | > End Sub
    | > | >
    | > | > the above code programmatically add a confirm script for a button
    in a
    | > | > datagrid template column....
    | > | >
    | > | > Also, you can use predefined script functions in aspx page
    also......
    | > | >
    | > | > Hope helps.
    | > | >
    | > | > Steven Cheng
    | > | > Microsoft Online Support
    | > | >
    | > | > Get Secure! www.microsoft.com/security
    | > | > (This posting is provided "AS IS", with no warranties, and confers
    no
    | > | > rights.)
    | > | > --------------------
    | > | > | From: "Eliyahu Goldin" <>
    | > | > | References: <>
    | > | > | Subject: Re: Call client script to update an item in a data grid
    | > | > | Date: Sun, 1 Jan 2006 10:04:22 +0200
    | > | > | Lines: 22
    | > | > | X-Priority: 3
    | > | > | X-MSMail-Priority: Normal
    | > | > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
    | > | > | X-RFC2646: Format=Flowed; Original
    | > | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
    | > | > | Message-ID: <>
    | > | > | Newsgroups:
    microsoft.public.dotnet.framework.aspnet.datagridcontrol
    | > | > | NNTP-Posting-Host: 212.143.94.3
    | > | > | Path:
    TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
    | > | > | Xref: TK2MSFTNGXA02.phx.gbl
    | > | > microsoft.public.dotnet.framework.aspnet.datagridcontrol:14995
    | > | > | X-Tomcat-NG:
    microsoft.public.dotnet.framework.aspnet.datagridcontrol
    | > | > |
    | > | > | Sure, you just need to setup client-side events. One way is to
    handle
    | > the
    | > | > | grid's ItemDataBound event. In the event you get access to the
    item
    | > (row)
    | > | > | elements and use their Attributes collection for adding
    client-side
    | > event
    | > | > | handlers.
    | > | > |
    | > | > | Eliyahu
    | > | > |
    | > | > | "LehrSJ" <> wrote in message
    | > | > | news:...
    | > | > | > Is there a way to run client script function or procedure to
    update
    | > | > data
    | > | > | > in a
    | > | > | > data grid? Say I have a textbox in the datagrid. The user
    enters
    | > some
    | > | > | > data.
    | > | > | > After exiting the textbox I'd like a client script to change
    the
    | > new
    | > | > value
    | > | > | > to
    | > | > | > all upper case or if it's a date format it a certain way.
    | > | > | >
    | > | > | > thanks
    | > | > | > --
    | > | > | > LehrSJ
    | > | > |
    | > | > |
    | > | > |
    | > | >
    | > | >
    | > |
    | >
    | >
    |
     
    Steven Cheng[MSFT], Jan 9, 2006
    #7
  8. LehrSJ

    LehrSJ Guest

    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


    "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?= <>
    > | References: <>
    > <>
    > <>
    > <>
    > <>
    > | 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: <>
    > | 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
    > |
    > |
    > | "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?= <>
    > | > | References: <>
    > | > <>
    > | > <>
    > | > | Subject: Re: Call client script to update an item in a data grid
    > | > | Date: Tue, 3 Jan 2006 06:51:03 -0800
    > | > | Lines: 84
    > | > | Message-ID: <>
    > | > | 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!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
    > | > | Xref: TK2MSFTNGXA02.phx.gbl
    > | > microsoft.public.dotnet.framework.aspnet.datagridcontrol:15004
    > | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
    > | > |
    > | > | Thanks. Is it possible to do this with a GridView or DetailsView?
    > | > | --
    > | > | LehrSJ
    > | > |
    > | > |
    > | > | "Steven Cheng[MSFT]" wrote:
    > | > |
    > | > | > Hi LehrSJ,
    > | > | >
    > | > | > As Eliyahu has mentioned, we can use the DataGrid's ItemDataBound
    > or
    > | > | > ItemCreated event to add the clientside script handler for the
    > certain
    > | > | > controls in the DataGrid Column.... e.g:
    > | > | >
    > | > | > Sub DataGrid_ItemCreated(Sender As Object, e As
    > DataGridItemEventArgs)
    > | > | > Select Case e.Item.ItemType
    > | > | > Case ListItemType.Item, ListItemType.AlternatingItem,
    > | > | > ListItemType.EditItem
    > | > | > Dim myDeleteButton As Button
    > | > | > myDeleteButton = e.Item.FindControl("btnDelete")
    > | > | > myDeleteButton.Attributes.Add("onclick",_
    > | > | > "return confirm('Are you sure you want to delete this
    > company?');")
    > | > | >
    > | > | > End Select
    > | > | > End Sub
    > | > | >
    > | > | > the above code programmatically add a confirm script for a button
    > in a
    > | > | > datagrid template column....
    > | > | >
    > | > | > Also, you can use predefined script functions in aspx page
    > also......
    > | > | >
    > | > | > Hope helps.
    > | > | >
    > | > | > Steven Cheng
    > | > | > Microsoft Online Support
    > | > | >
    > | > | > Get Secure! www.microsoft.com/security
    > | > | > (This posting is provided "AS IS", with no warranties, and confers
    > no
    > | > | > rights.)
    > | > | > --------------------
    > | > | > | From: "Eliyahu Goldin" <>
    > | > | > | References: <>
    > | > | > | Subject: Re: Call client script to update an item in a data grid
    > | > | > | Date: Sun, 1 Jan 2006 10:04:22 +0200
    > | > | > | Lines: 22
    > | > | > | X-Priority: 3
    > | > | > | X-MSMail-Priority: Normal
    > | > | > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
    > | > | > | X-RFC2646: Format=Flowed; Original
    > | > | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
    > | > | > | Message-ID: <>
    > | > | > | Newsgroups:
    > microsoft.public.dotnet.framework.aspnet.datagridcontrol
    > | > | > | NNTP-Posting-Host: 212.143.94.3
    > | > | > | Path:
    > TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
    > | > | > | Xref: TK2MSFTNGXA02.phx.gbl
    > | > | > microsoft.public.dotnet.framework.aspnet.datagridcontrol:14995
    > | > | > | X-Tomcat-NG:
    > microsoft.public.dotnet.framework.aspnet.datagridcontrol
    > | > | > |
    > | > | > | Sure, you just need to setup client-side events. One way is to
    > handle
    > | > the
    > | > | > | grid's ItemDataBound event. In the event you get access to the
    > item
    > | > (row)
    > | > | > | elements and use their Attributes collection for adding
    > client-side
    > | > event
    > | > | > | handlers.
    > | > | > |
    > | > | > | Eliyahu
    > | > | > |
    > | > | > | "LehrSJ" <> wrote in message
    > | > | > | news:...
    > | > | > | > Is there a way to run client script function or procedure to
    > update
    > | > | > data
    > | > | > | > in a
    > | > | > | > data grid? Say I have a textbox in the datagrid. The user
    > enters
    > | > some
    > | > | > | > data.
    > | > | > | > After exiting the textbox I'd like a client script to change
    > the
    > | > new
    > | > | > value
    > | > | > | > to
    > | > | > | > all upper case or if it's a date format it a certain way.
    > | > | > | >
    > | > | > | > thanks
    > | > | > | > --
    > | > | > | > LehrSJ
    > | > | > |
    > | > | > |
    > | > | > |
    > | > | >
    > | > | >
    > | > |
    > | >
    > | >
    > |
    >
    >
     
    LehrSJ, Jan 10, 2006
    #8
  9. 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?= <>
    | References: <>
    <>
    <>
    <>
    <>
    <>
    <>
    | 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: <>
    | 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
    |
    |
    | "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?= <>
    | > | References: <>
    | > <>
    | > <>
    | > <>
    | > <>
    | > | 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: <>
    | > | 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
    | > |
    | > |
    | > | "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?= <>
    | > | > | References: <>
    | > | > <>
    | > | > <>
    | > | > | Subject: Re: Call client script to update an item in a data grid
    | > | > | Date: Tue, 3 Jan 2006 06:51:03 -0800
    | > | > | Lines: 84
    | > | > | Message-ID: <>
    | > | > | 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!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
    | > | > | Xref: TK2MSFTNGXA02.phx.gbl
    | > | > microsoft.public.dotnet.framework.aspnet.datagridcontrol:15004
    | > | > | X-Tomcat-NG:
    microsoft.public.dotnet.framework.aspnet.datagridcontrol
    | > | > |
    | > | > | Thanks. Is it possible to do this with a GridView or DetailsView?
    | > | > | --
    | > | > | LehrSJ
    | > | > |
    | > | > |
    | > | > | "Steven Cheng[MSFT]" wrote:
    | > | > |
    | > | > | > Hi LehrSJ,
    | > | > | >
    | > | > | > As Eliyahu has mentioned, we can use the DataGrid's
    ItemDataBound
    | > or
    | > | > | > ItemCreated event to add the clientside script handler for the
    | > certain
    | > | > | > controls in the DataGrid Column.... e.g:
    | > | > | >
    | > | > | > Sub DataGrid_ItemCreated(Sender As Object, e As
    | > DataGridItemEventArgs)
    | > | > | > Select Case e.Item.ItemType
    | > | > | > Case ListItemType.Item, ListItemType.AlternatingItem,
    | > | > | > ListItemType.EditItem
    | > | > | > Dim myDeleteButton As Button
    | > | > | > myDeleteButton = e.Item.FindControl("btnDelete")
    | > | > | > myDeleteButton.Attributes.Add("onclick",_
    | > | > | > "return confirm('Are you sure you want to delete this
    | > company?');")
    | > | > | >
    | > | > | > End Select
    | > | > | > End Sub
    | > | > | >
    | > | > | > the above code programmatically add a confirm script for a
    button
    | > in a
    | > | > | > datagrid template column....
    | > | > | >
    | > | > | > Also, you can use predefined script functions in aspx page
    | > also......
    | > | > | >
    | > | > | > Hope helps.
    | > | > | >
    | > | > | > Steven Cheng
    | > | > | > Microsoft Online Support
    | > | > | >
    | > | > | > Get Secure! www.microsoft.com/security
    | > | > | > (This posting is provided "AS IS", with no warranties, and
    confers
    | > no
    | > | > | > rights.)
    | > | > | > --------------------
    | > | > | > | From: "Eliyahu Goldin" <>
    | > | > | > | References:
    <>
    | > | > | > | Subject: Re: Call client script to update an item in a data
    grid
    | > | > | > | Date: Sun, 1 Jan 2006 10:04:22 +0200
    | > | > | > | Lines: 22
    | > | > | > | X-Priority: 3
    | > | > | > | X-MSMail-Priority: Normal
    | > | > | > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
    | > | > | > | X-RFC2646: Format=Flowed; Original
    | > | > | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
    | > | > | > | Message-ID: <>
    | > | > | > | Newsgroups:
    | > microsoft.public.dotnet.framework.aspnet.datagridcontrol
    | > | > | > | NNTP-Posting-Host: 212.143.94.3
    | > | > | > | Path:
    | > TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
    | > | > | > | Xref: TK2MSFTNGXA02.phx.gbl
    | > | > | > microsoft.public.dotnet.framework.aspnet.datagridcontrol:14995
    | > | > | > | X-Tomcat-NG:
    | > microsoft.public.dotnet.framework.aspnet.datagridcontrol
    | > | > | > |
    | > | > | > | Sure, you just need to setup client-side events. One way is
    to
    | > handle
    | > | > the
    | > | > | > | grid's ItemDataBound event. In the event you get access to
    the
    | > item
    | > | > (row)
    | > | > | > | elements and use their Attributes collection for adding
    | > client-side
    | > | > event
    | > | > | > | handlers.
    | > | > | > |
    | > | > | > | Eliyahu
    | > | > | > |
    | > | > | > | "LehrSJ" <> wrote in message
    | > | > | > | news:...
    | > | > | > | > Is there a way to run client script function or procedure
    to
    | > update
    | > | > | > data
    | > | > | > | > in a
    | > | > | > | > data grid? Say I have a textbox in the datagrid. The user
    | > enters
    | > | > some
    | > | > | > | > data.
    | > | > | > | > After exiting the textbox I'd like a client script to
    change
    | > the
    | > | > new
    | > | > | > value
    | > | > | > | > to
    | > | > | > | > all upper case or if it's a date format it a certain way.
    | > | > | > | >
    | > | > | > | > thanks
    | > | > | > | > --
    | > | > | > | > LehrSJ
    | > | > | > |
    | > | > | > |
    | > | > | > |
    | > | > | >
    | > | > | >
    | > | > |
    | > | >
    | > | >
    | > |
    | >
    | >
    |
     
    Steven Cheng[MSFT], Jan 10, 2006
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sunil Thomas
    Replies:
    0
    Views:
    530
    Sunil Thomas
    Sep 29, 2003
  2. Jack Smith
    Replies:
    2
    Views:
    1,553
    Nelson
    Nov 11, 2004
  3. Ryan Ternier

    Data Grid - Update Columns

    Ryan Ternier, Feb 16, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    1,023
    Ryan Ternier
    Feb 16, 2005
  4. Shahid Saleem
    Replies:
    1
    Views:
    747
    =?Utf-8?B?RWx0b24gVw==?=
    Aug 26, 2005
  5. Mark Janssen
    Replies:
    0
    Views:
    157
    Mark Janssen
    Apr 12, 2013
Loading...

Share This Page