Results 1 to 6 of 6

Thread: Calling function in hyperlink?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2004
    Location
    cainta
    Posts
    80

    Calling function in hyperlink?

    Hello,

    I want to call my delete function after clicking the delete hyperlink of my grid. is this possible? how?


    Thanks

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Calling function in hyperlink?

    You can handle the hyperlink's click in the DataGrid's ItemCommand event. Based upon the Item and ItemIndex of the hyperlink clicked, you can perform the corresponding delete/delete function.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2004
    Location
    cainta
    Posts
    80

    Re: Calling function in hyperlink?

    Quote Originally Posted by mendhak
    You can handle the hyperlink's click in the DataGrid's ItemCommand event. Based upon the Item and ItemIndex of the hyperlink clicked, you can perform the corresponding delete/delete function.
    mendhak,

    can you give me a sample script?

    Thanks

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Calling function in hyperlink?

    Your template column will look like this:

    Code:
    <asp:TemplateColumn>
    						<ItemTemplate>
    							<asp:LinkButton ID="hyl1" Runat="server">mylink</asp:LinkButton>
    						</ItemTemplate>
    					</asp:TemplateColumn>
    A linkbutton can be handled server side, so in the itemcommand event of the datagrid:

    VB Code:
    1. Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.ItemCommand
    2.         Response.Write("Index: " & e.Item.ItemIndex.ToString())
    3.     End Sub

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jun 2004
    Location
    cainta
    Posts
    80

    Re: Calling function in hyperlink?

    Thanks

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Calling function in hyperlink?

    Welcome.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width