473,405 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Datagrid confirm('some msg');

Can some one point me or show me some sample code on how
to confirm a delete when the user selects an item from the
datagrid.

I am able to do so only when is a push type button, but I
want to put in the grid the text word "Delete" like a
link...and use the confirm as well...

thanks
jayuya
Nov 17 '05 #1
2 2036
No problem:

Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound

Dim item As DataGridItem = e.Item

Dim label As String = "Carrier"

Dim value As String = item.Cells(2).Text

item.Cells(DELETE_COL_NUM).Attributes.Item("onClic k") = DeleteConfirmJava(label, value) ' DELETE_COL_NUM is the column to affect...

End Sub

Public Function DeleteConfirmJava(ByVal Label As String, ByVal Value As String) As String

Dim OpInfo As String

OpInfo = "\t DELETE <Object>:\n"

OpInfo &= "\t============\n"

OpInfo &= "<VALUE>\n"

OpInfo &= "\nYou have asked to delete this <Object>.\n"

OpInfo &= "Are you SURE this is what you want?"

OpInfo = "return confirm('" & OpInfo & "');"

' - put in label and values

OpInfo = Regex.Replace(OpInfo, "<Object>", Label, RegexOptions.IgnoreCase)

OpInfo = Regex.Replace(OpInfo, "<Value>", Value, RegexOptions.IgnoreCase)

Return OpInfo

End Function

"jayuya" <ja****@cox.net> wrote in message news:0a****************************@phx.gbl...
Can some one point me or show me some sample code on how
to confirm a delete when the user selects an item from the
datagrid.

I am able to do so only when is a push type button, but I
want to put in the grid the text word "Delete" like a
link...and use the confirm as well...

thanks
jayuya

Nov 17 '05 #2
David,

Thanks a lot, It worked great...:-)

jayuya
-----Original Message-----
No problem:

Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemDataBound
Dim item As DataGridItem = e.Item

Dim label As String = "Carrier"

Dim value As String = item.Cells(2).Text

item.Cells(DELETE_COL_NUM).Attributes.Item("onCli ck") = DeleteConfirmJava(label, value) ' DELETE_COL_NUM is the
column to affect...
End Sub

Public Function DeleteConfirmJava(ByVal Label As String, ByVal Value As String) As String
Dim OpInfo As String

OpInfo = "\t DELETE <Object>:\n"

OpInfo &= "\t============\n"

OpInfo &= "<VALUE>\n"

OpInfo &= "\nYou have asked to delete this <Object>.\n"

OpInfo &= "Are you SURE this is what you want?"

OpInfo = "return confirm('" & OpInfo & "');"

' - put in label and values

OpInfo = Regex.Replace(OpInfo, "<Object>", Label, RegexOptions.IgnoreCase)
OpInfo = Regex.Replace(OpInfo, "<Value>", Value, RegexOptions.IgnoreCase)
Return OpInfo

End Function

"jayuya" <ja****@cox.net> wrote in message

news:0a****************************@phx.gbl...
Can some one point me or show me some sample code on how to confirm a delete when the user selects an item from the datagrid.

I am able to do so only when is a push type button, but I want to put in the grid the text word "Delete" like a
link...and use the confirm as well...

thanks
jayuya

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: norfernuman | last post by:
This function works fine in all mozilla based browsers, but in IE6 the confirm shows up, but it doesn't change location, is there a way to tweak this for IE and Mozilla use? Thanks, - NN ...
2
by: Peter | last post by:
I have a DataGrid control on a form and I used the Auto Format feature to format the grid. The problem is now if I resize a column in my code I loose some of the formats - some of the grid colors...
0
by: Chris Fink | last post by:
My goal is to have an ASP.NET checkbox server tag with it's autopostback set to true, that when clicked will run the checkbox's CheckedChanged event. However, I would like to try to add a...
4
by: louise raisbeck | last post by:
I want to run some server code but before I do i want to ask the user if they are sure using a javascript confirm. I'm confused as to how to do this. I can build a javascript string then do...
3
by: Alexander Widera | last post by:
Hi, at first a little bit of the code ... <ASP:DataGrid id="an" runat="server" AutoGenerateColumns="false"> <Columns> <asp:BoundColumn DataField="status" HeaderText="status" /> </Columns>...
0
by: Tim::.. | last post by:
Can someone please tell me how I can get the following JavaScript to work inside this datagrid! What I'm trying to do is to have a layer that shows up with an image of an employee when you...
2
by: Ray Booysen | last post by:
Hi all I have a collection of Invoices that I bind to a datagrid. Some of these invoices have been processed and you can tell this via a property in the invoice class called DateProcessed. If...
3
by: OccasionalFlyer | last post by:
I have become owner of some Javascript code that displays a message through the confirm() function. I have a uwser reuqest to make the font size of this message larger. Can this be done? I don't...
1
by: Steven Van Eyck | last post by:
Hi there There are probably lots of questions being posted about datagrids, but I can't resist... ;-) Here's my issue: I have an aspx page with a datagrid in which I manually declare the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.