The term Private in VB means that only the class which the subroutine is in
has access to whatever you declare as private.  Public means any class can
access it.  If you define a subroutine to run when an event is triggered
then you must give at least protected access to the subroutine.

 

Partial datagrid code. 

 

id="dgResults" runat="server" Font-Size="X-Small"
OnItemDataBound="dgResults_ItemDataBound" OnDeleteCommand="dgResults_Delete"
DataKeyField="Emp_No" GridLines="None"

 

As you can see the subroutine named dgresults_Delete will run when the event
onDeleteCommand is triggered.

 

There are good articles by Scott Mitchell on 4guys that should help you

 

http://aspnet.4guysfromrolla.com/articles/040502-1.aspx
<http://aspnet.4guysfromrolla.com/articles/040502-1.aspx> 

 

 

-----Original Message-----
From: Anna Leon [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 14, 2004 9:24 PM
To: [EMAIL PROTECTED]
Subject: RE: [AspNetAnyQuestionIsOk] How to Confirm a Delete in an ASP.NET
Datagrid

 

Why do you put "Public" or "Private" in the beginning
for the subroutines? Can I leave it out in VB.Net?


--- Eric Cantrall <[EMAIL PROTECTED]> wrote:

> This is the way I handle deletes...You must know
> when to process the events
> that are triggered.
> 
>  
> 
> On the ItemDataBound run a routine to bind code
> similar to this to the
> datagrid.
> 
>  
> 
> Public Sub dgresults_ItemDataBound(ByVal Sender As
> Object, ByVal e As
> System.Web.UI.WebControls.DataGridItemEventArgs)
> 
>  
> 
>         If e.Item.ItemType <> ListItemType.Header
> And e.Item.ItemType <>
> ListItemType.Footer Then
> 
>             Dim Deletebutton As LinkButton =
> e.Item.Cells(0).Controls(0)
> 
>             Deletebutton.Attributes("onclick") =
> "javascript:return
> confirm('Are you sure you want to delete Employee "
> & _
> 
>                 DataBinder.Eval(e.Item.DataItem,
> "Emp_No") & "?')"
> 
>         End If
> 
>     End Sub
> 
>  
> 
> Then, if the users selects OK the OnDelete Event is
> triggered and I set a
> subroutine similar to this:
> 
>  
> 
> Public Sub dgResults_Delete(ByVal Sender As Object,
> ByVal e As
> System.Web.UI.WebControls.DataGridCommandEventArgs)
> Handles
> dgResults.DeleteCommand
> 
>         Dim index As Integer
> 
>         index = dgResults.DataKeys(e.Item.ItemIndex)
> 
>         ' Add code to delete data from data source
> 
>  
> 
>         Dim sqlstr As String = "DELETE FROM Employee
> " & _
> 
>             "WHERE Emp_No = " & index & ""
> 
>         Dim DeleteCommand As New SqlCommand(sqlstr,
> aConnection)
> 
>         aConnection.Open()
> 
>         DeleteCommand.ExecuteNonQuery()
> 
>  
> 
>         dgResults.DataBind()
> 
>     End Sub
> 
>  
> 
> --Eric 
> 
>  
> 
> -----Original Message-----
> From: Greg Ewing [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, September 14, 2004 4:38 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [AspNetAnyQuestionIsOk] How to Confirm
> a Delete in an ASP.NET
> Datagrid
> 
>  
> 
> No, if the person clicks yes the Button Click event
> will be sent to the
> server where you will need to process it and delete
> the record.  If they
> click cancel the click event will be cancelled and
> the user will stay on the
> current page.
> 
> Greg Ewing [MVP]
> www.citidc.com 
> 
> ----------------------------------------
> From: Anna Leon <[EMAIL PROTECTED]>
> Sent: Tuesday, September 14, 2004 1:29 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [AspNetAnyQuestionIsOk] How to Confirm
> a Delete in an ASP.NET
> Datagrid 
> 
> After hitting yes, will the record be deleted then?
> 
> --- [EMAIL PROTECTED] wrote:
> 
> > Add this line of code after Page_Load sub in your
> > code behind, assuming that you named your delete
> > button "btnDelete".
> > 
> > btnDelete.Attributes.Add("onclick",
> > "javascript:if(confirm('Are you sure you want to
> > delete this item?')== false) return false;")
> > 
> > 
> > 
> > 
> > _____ 
> > 
> > 
> > Zehra Altug | Intranet Applications Developer |
> > Information Technology Group | Media General, Inc.
> |
> > Tel: (804) 649-6149
> > 
> > 
> > 
> > -----Original Message-----
> > From: sas0riza [ mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, September 14, 2004 4:02 PM
> > To: [EMAIL PROTECTED]
> > Subject: [AspNetAnyQuestionIsOk] How to Confirm a
> > Delete in an ASP.NET
> > Datagrid
> > 
> > 
> > I would like to delete a record, but only after
> > confirmation.
> > 
> > I have this JS function:
> > 
> > 
> > function confirm_delete()
> > {
> > if (confirm("Are you sure you want to delete this
> > item?")==true)
> > return true;
> > else
> > return false;
> > }
> >  
> > 
> > 
> > How do I incorporate it into my code?
> > 
> > 
> > 
> > 
> > 
> > 
> > Yahoo! Groups Links
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > [Non-text portions of this message have been
> > removed]
> > 
> > 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam
> protection around 
> http://mail.yahoo.com <http://mail.yahoo.com>  <http://mail.yahoo.com
<http://mail.yahoo.com> >  
> 
> 
> Yahoo! Groups Links
> 
> 
> 
> 
> 
> [Non-text portions of this message have been
> removed]
> 
> 
> 
> 
> 
> 
> Yahoo! Groups Sponsor
> 
> 
> 
> ADVERTISEMENT
>  
>
<http://us.ard.yahoo.com/SIG=129r0a6t6/M=298184.5285298.6392945.3001176/D=gr
<http://us.ard.yahoo.com/SIG=129r0a6t6/M=298184.5285298.6392945.3001176/D=gr
> 
>
oups/S=1705006764:HM/EXP=1095280706/A=2352667/R=0/SIG=11t4iivpf/*http:/www.n
> etflix.com/Default?mqso=60185359&partid=5285298>
> click here
> 
> 
>  
>
<http://us.adserver.yahoo.com/l?M=298184.5285298.6392945.3001176/D=groups/S=
<http://us.adserver.yahoo.com/l?M=298184.5285298.6392945.3001176/D=groups/S=
> 
> :HM/A=2352667/rand=868985580> 
> 
>  
> 
>   _____  
> 
> Yahoo! Groups Links
> 
> *         To visit your group on the web, go to:
> http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/> 
>
<http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/> >
> 
>   
> 
> *         To unsubscribe from this group, send an
> email to:
> [EMAIL PROTECTED]
>
<mailto:[EMAIL PROTECTED]
> e> 
>   
> 
> *         Your use of Yahoo! Groups is subject to
> the Yahoo! Terms of
> Service <http://docs.yahoo.com/info/terms/
<http://docs.yahoo.com/info/terms/> > . 
> 
> 
> 
> [Non-text portions of this message have been
> removed]
> 
> 



      
            
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail <http://promotions.yahoo.com/new_mail>






Yahoo! Groups Sponsor



ADVERTISEMENT
 
<http://us.ard.yahoo.com/SIG=12917il7r/M=295196.4901138.6071305.3001176/D=gr
oups/S=1705006764:HM/EXP=1095297901/A=2128215/R=0/SIG=10se96mf6/*http:/compa
nion.yahoo.com> click here


 
<http://us.adserver.yahoo.com/l?M=295196.4901138.6071305.3001176/D=groups/S=
:HM/A=2128215/rand=301617681> 

 

  _____  

Yahoo! Groups Links

*         To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/> 
  

*         To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]
e> 
  

*         Your use of Yahoo! Groups is subject to the Yahoo! Terms of
<http://docs.yahoo.com/info/terms/>  Service. 



[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to