Results 1 to 5 of 5

Thread: RESOLVED!! VB.NET equivalent

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member ARPRINCE's Avatar
    Join Date
    Mar 2003
    Location
    Pinoy in NJ
    Posts
    381

    Question RESOLVED!! VB.NET equivalent

    I have this code in a tutorial but was coded in c#. What is the equivalent code in VB.NET?

    VB Code:
    1. protected void myDataGrid_OnItemDataBound(object sender, DataGridItemEventArgs e)
    2. {
    3.  
    4.   if(e.Item.FindControl("DeleteLink") != null)
    5.   {
    6.     ((LinkButton) e.Item.FindControl("DeleteLink")).Attributes.Add("onClick", "return confirm('Are you sure you wish to delete this item?');");
    7.  
    8.   }
    9. }

    Basically I have a DataGrid with a DELETE linkbutton on the first column (id=DeleteMe) as a template. When user clicks on the DELETE link, it is suppose to prompt a confirmation.

    I tried converting to VB but I am getting an error Specified argument was out of the range of valid values. Parameter name: index
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.


    VB Code:
    1. Sub dgCustomer_OnItemDataBound(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
    2.         If Not IsDBNull(e.Item.FindControl("DeleteMe")) Then
    3.             Dim deleteButton As LinkButton = e.Item.Cells(0).Controls(0)   '<-- ERROR HERE
    4.             deleteButton.Attributes("onclick") = "javascript:return Confirm('Are you sure you want to delete this record?');"
    5.         End If
    6.     End Sub
    Last edited by ARPRINCE; Apr 23rd, 2004 at 11:21 AM.

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