Perform JavaScript Client Side Confirmation from a VB.NET DataGrid

Hi,

I when I delete an item from the database through a Datagrid I want to get a messagebox poping
up to give me the choise to Confirm it...in case I clicked the wrong item....the way it works now it just deletes it....can any one help me with an Example I have no Idea how to do this...I found an article in C# but it didnt help me at all.

here is my source code

<asp:DataGrid ID="dgCustList" Runat="server" AutoGenerateColumns="False" DataKeyField="id" AlternatingItemStyle-BackColor="#F6F6F6" HeaderStyle-BackColor="#C4B58E" CellSpacing="0" CellPadding="2" GridLines="Vertical" Width="100%" BorderWidth="0">
 <Columns>
  <asp:HyperLinkColumn DataTextField="Name" DataNavigateUrlField="id" DataNavigateUrlFormatString="cust_detail.aspx?id={0}" HeaderText="Rubrik" />
   <asp:BoundColumn DataField="email" HeaderText="Email" ItemStyle-Width="160" ReadOnly="True" />
   <asp:TemplateColumn HeaderText="Publiserad" ItemStyle-Width="80">
   <ItemTemplate>
    <%#Databinder.Eval(Container.DataItem, "posted", "{0:d}") %>
   </ItemTemplate>
   <EditItemTemplate>
   <asp:TextBox ID="edit_tbPosted" CssClass="time" Runat="server" Width="250" Text='<%# Databinder.Eval(Container.DataItem, "posted")%>' />
   </EditItemTemplate>
  </asp:TemplateColumn>
  <asp:EditCommandColumn EditText="Ändra" CancelText="Avbryt" UpdateText="Spara" ItemStyle-HorizontalAlign="Right" />
  <asp:ButtonColumn Text="Radera" ButtonType="LinkButton" CommandName="Delete" ItemStyle-HorizontalAlign="Right" />
 </Columns>
</asp:DataGrid>


-Code Behind-
Sub dgCustList_Delete(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgCustList.DeleteCommand

pnlNewCust.Visible = False
dgCustList.Visible = False
btnAddCust.Visible = False

Dim intCustId = dgCustList.DataKeys(Convert.ToInt32(e.Item.ItemIndex))
Dim Data As DataObjVB
Data =
New DataObjVB()
dgCustList.DataSource = Data.DeleteCustomer(intCustId)
dgCustList.DataBind()

lblMessage.Text = "the record has been deleted"
End Sub

--------------

I hope Someone can help me cause im getting nuts here...I havent been programming enough for the last two years

Thanks
/Magnus


Magnus
0
nbop
1/24/2006 8:15:00 PM
asp.net.client-side 24353 articles. 1 followers. Follow

3 Replies
986 Views

Similar Articles

[PageSpeed] 58


Private Sub dgCustList_ItemCreated(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgCustList.ItemCreated

Select Case e.Item.ItemType

Case ListItemType.Item, ListItemType.AlternatingItem, ListItemType.EditItem

Dim myTableCell As TableCell

myTableCell = e.Item.Cells(4)   ' 4 indicates the column number which has delete button

Dim myDeleteButton As LinkButton

myDeleteButton = myTableCell.Controls(0)

myDeleteButton.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this ?');")

End Select

End Sub

0
kalyanipradeep
1/25/2006 12:29:00 PM

thanks I tried it but got this message

Specified argument was out of the range of valid values. Parameter name: index

I guess that ought to be related to the index of the Datakeyfield generated from in the Datagrid?
how do I fix that part..?

thank you

/Magnus


Magnus
0
nbop
1/25/2006 9:27:48 PM
Hi,

        Sorry for the late reply. I was on leave. The error is due to the index which you have specified is wrong. U have to change the index in,

              myTabelcell=e.item.cells(4) ,
As i have mentioned earlier, cells(4)  indicates the column number in which you have the delete link button. The indexes of the grid will start from zero. change the index and see it will really work.

kalyani
0
kalyanipradeep
1/28/2006 6:39:42 AM
Reply:

Web resources about - Perform JavaScript Client Side Confirmation from a VB.NET DataGrid - asp.net.client-side

Confirmation - Wikipedia, the free encyclopedia
A bishop administering Confirmation. Rogier van der Weyden , The Seven Sacraments , 15th century. normally carried out through anointing , the ...

Confirmation - Wikipedia, the free encyclopedia
A bishop administering Confirmation. Rogier van der Weyden , The Seven Sacraments , 15th century. normally carried out through anointing , the ...

Facebook Reportedly Acquires Gowalla, No Confirmation From Either Company
... “most” of its employees and founder Josh Williams over to Palo Alto headquarters to work on Timeline, according to CNN. We could not get confirmation ...

Twitter reactions to the #Fed confirmation
... over Twitter — the last time that a new chairperson was appointed, Twitter wasn’t around. Within half an hour of the milestone confirmation, ...

Senate Confirmation Hearing (200910150008HQ) - Flickr - Photo Sharing!
U.S. Sen. Jay Rockefeller, D-W.Va., Chairman of the of the Senate Committee on Commerce, Science and Transportation, makes a point during the ...

Wet Hot American Summer: First Day of Camp - Cast Confirmation - Netflix - HD - YouTube
The counselors are confirmed for Wet Hot American Summer: First Day of Camp, a limited 8-episode series coming to Netflix just in time for summer. ...

Republicans force delay on Hagel confirmation
... answers from US President Barack Obama's pick to head the Pentagon have forced Senate leaders to delay a vote, throwing Chuck Hagel's confirmation ...

Is this confirmation Prince George and Princess Charlotte's nanny is Mary Poppins?
The christening of Princess Charlotte was touted as &quot;modern&quot;. No one told the nanny.

Jurgen Klopp Liverpool, Jurgen Klopp news, Jurgen Klopp Liverpool confirmation
JURGEN Klopp is officially the new Liverpool manager.

Is this confirmation Prince George and Princess Charlotte's nanny is Mary ...
Sydney Morning Herald Is this confirmation Prince George and Princess Charlotte's nanny is Mary ... Sydney Morning Herald There were many ...

Resources last updated: 1/23/2016 3:29:48 PM