|
-
Jan 8th, 2003, 01:35 PM
#1
Thread Starter
Frenzied Member
confirmation box
I am having some difficulty getting my message box to display. If I use a regular asp button, I place the javascript in the page_load event and it works fine. The problem is this button I'm using now is a datagrid button. Is there another procedure I can declare this code in?
Code:
Public Sub DeleteBid(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.DeleteCommand
'check which row has been selected
Dim selectedRow As String = DataGrid1.DataKeys(e.Item.ItemIndex)
Dim btnDelete As Button
btnDelete = e.Item.Cells(4).Controls(0) '<---5th column, first control
btnDelete.Attributes("onclick") = "javascript:return confirm('Are you sure you want to delete \n Bid Record " & selectedRow & "?')"
-
Jan 8th, 2003, 06:01 PM
#2
Addicted Member
Use the DataGrid's ItemCreated Routine:
Code:
Private Sub dg_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dg.ItemCreated
Select Case e.Item.ItemType
Case ListItemType.Item, ListItemType.AlternatingItem, ListItemType.EditItem
Dim cmdDelete As Button = e.Item.FindControl("cmdDelete")
If Not cmdDelete Is Nothing Then
Dim x As Common.DbDataRecord = e.Item.DataItem
Dim sName As String
If Not x Is Nothing Then
sName = x.GetValue(1)
End If
cmdDelete.Attributes.Add("onclick", "return confirm('Are you sure you want to delete " & sName & "?');")
End If
End Select
-Daryl
"Two More Rolls of Duct tape, and the world is mine!"
VB.NET Guru
-
Jan 9th, 2003, 03:15 AM
#3
Thread Starter
Frenzied Member
still no message box displays...
-
Jan 9th, 2003, 12:58 PM
#4
Addicted Member
Are you using a Template Column? You'll need to do that.
Code:
<asp:TemplateColumn>
<ItemTemplate>
<asp:Button id="cmdDelete" runat="server" Text="Delete"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
-Daryl
"Two More Rolls of Duct tape, and the world is mine!"
VB.NET Guru
-
Jan 9th, 2003, 02:30 PM
#5
Thread Starter
Frenzied Member
it's not a button though...it's a buttonColumn
Code:
<asp:ButtonColumn Text="Delete" ButtonType="PushButton" HeaderText="DELETE" CommandName="Delete"></asp:ButtonColumn>
-
Jan 9th, 2003, 02:45 PM
#6
Addicted Member
If you use a button column you leave the button in control of the datagrid, if you want to add attributes you have to make your own button column by using a Template Column as shown above. (Anyone can correct me if I'm wrong, but this is the only way I've found it to work.)
-Daryl
"Two More Rolls of Duct tape, and the world is mine!"
VB.NET Guru
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|