473,769 Members | 7,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Client-Side User Confirmation Within DataGrid

Hi, I use a datagrid with a delete command. I create a validation on
the delete command and i have a problem: the confirmation message is
supposes to appear each time I do this command but it appear just
sometimes. Is anyone can tell me how to get this message everytime I
use this command ?
thanks
this is my code in the aspx.vb :

Private Sub DataGrid1_ItemD ataBound(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Data GridItemEventAr gs) Handles
DataGrid1.ItemD ataBound

If (e.Item.ItemTyp e = ListItemType.It em) Then
Dim control As WebControl
For Each control In e.Item.Controls
If CType(e.Item.Co ntrols(4).Contr ols(0),
LinkButton).Com mandName = "Delete" Then
CType(e.Item.Co ntrols(4).Contr ols(0),
WebControl).Att ributes.Add("on click", "test()")
End If
Next
End If

End Sub
Private Sub DataGrid1_Delet eCommand(ByVal source As Object, ByVal e As
System.Web.UI.W ebControls.Data GridCommandEven tArgs) Handles
DataGrid1.Delet eCommand
cnn.Open()
Dim Sql As String
Dim matrans As OdbcTransaction = cnn.BeginTransa ction
Dim cmd As New OdbcCommand
DataGrid1.EditI temIndex = e.Item.ItemInde x
Sql = "Delete from composition where fiberid=" &
e.Item.Cells(0) .Text & "and tuileid=1"
DataGrid1.EditI temIndex = -1
cmd.Connection = cnn
cmd.Transaction = matrans
Try
cmd.CommandType = CommandType.Tex t
cmd.CommandText = Sql
cmd.ExecuteNonQ uery()
matrans.Commit( )
Catch ex As Exception
Response.Write( DataGrid1.DataK eyField)
Response.Write( ex.Message())
Finally
cnn.Close()
ActualiserListe ()
End Try
End Sub

.. This is what i put in apx:

<script language="JavaS cript" />
<!--
function test()
{
if (window.confirm ("Do you want to delete?"))
{
}
else
{
event.returnVal ue = false;
}
}
//-->
</SCRIPT>
<form id="Form1" method="post" runat="server">
<table width="1136" border="2">
<TR><td>
<asp:datagrid id="DataGrid1" runat="server" Width="560px"
AutoGenerateCol umns="False" Height="106px">
<Columns>
<asp:BoundColum n Visible="False" DataField="fibe rid" ReadOnly="True"
HeaderText="Num fibre"></asp:BoundColumn >
<asp:TemplateCo lumn HeaderText="Fib re">
<ItemTemplate >
<asp:Label id=lblfibredg runat="server" Text='<%#
Container.DataI tem("namefiber" ) %>'>
</asp:Label>
</ItemTemplate>
<EditItemTempla te>
<asp:DropDownLi st id="lstdg" runat="server"> </asp:DropDownLis t>
</EditItemTemplat e>
</asp:TemplateCol umn>
<asp:BoundColum n DataField="pour centage"
HeaderText="Pou rcentage"></asp:BoundColumn >
<asp:EditComman dColumn ButtonType="Lin kButton" UpdateText="Enr egistrer
modification" HeaderText="Mod ifier la ligne"
CancelText="Ann uler" EditText="Modif ier"></asp:EditCommand Column>
<asp:ButtonColu mn Text="Supprimer " HeaderText="Sup primer la ligne"
CommandName="De lete"></asp:ButtonColum n>
</Columns>
</asp:datagrid></td></tr>
</table>
</form>

Jun 28 '06 #1
2 1971
Hi Simon,

Is your test for the ItemType correct? Don't forget that content also
appears in alternating item types. You probably need something like this,

If e.Item.ItemType = ListItemType.It em Or _
e.Item.ItemType = ListItemType.Al ternatingItem Then

Let us know?

Ken
Microsoft MVP [ASP.NET]

<si********@hot mail.com> wrote in message
news:11******** **************@ x69g2000cwx.goo glegroups.com.. .
Hi, I use a datagrid with a delete command. I create a validation on
the delete command and i have a problem: the confirmation message is
supposes to appear each time I do this command but it appear just
sometimes. Is anyone can tell me how to get this message everytime I
use this command ?
thanks
this is my code in the aspx.vb :

Private Sub DataGrid1_ItemD ataBound(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Data GridItemEventAr gs) Handles
DataGrid1.ItemD ataBound

If (e.Item.ItemTyp e = ListItemType.It em) Then
Dim control As WebControl
For Each control In e.Item.Controls
If CType(e.Item.Co ntrols(4).Contr ols(0),
LinkButton).Com mandName = "Delete" Then
CType(e.Item.Co ntrols(4).Contr ols(0),
WebControl).Att ributes.Add("on click", "test()")
End If
Next
End If

End Sub
Private Sub DataGrid1_Delet eCommand(ByVal source As Object, ByVal e As
System.Web.UI.W ebControls.Data GridCommandEven tArgs) Handles
DataGrid1.Delet eCommand
cnn.Open()
Dim Sql As String
Dim matrans As OdbcTransaction = cnn.BeginTransa ction
Dim cmd As New OdbcCommand
DataGrid1.EditI temIndex = e.Item.ItemInde x
Sql = "Delete from composition where fiberid=" &
e.Item.Cells(0) .Text & "and tuileid=1"
DataGrid1.EditI temIndex = -1
cmd.Connection = cnn
cmd.Transaction = matrans
Try
cmd.CommandType = CommandType.Tex t
cmd.CommandText = Sql
cmd.ExecuteNonQ uery()
matrans.Commit( )
Catch ex As Exception
Response.Write( DataGrid1.DataK eyField)
Response.Write( ex.Message())
Finally
cnn.Close()
ActualiserListe ()
End Try
End Sub

. This is what i put in apx:

<script language="JavaS cript" />
<!--
function test()
{
if (window.confirm ("Do you want to delete?"))
{
}
else
{
event.returnVal ue = false;
}
}
//-->
</SCRIPT>
<form id="Form1" method="post" runat="server">
<table width="1136" border="2">
<TR><td>
<asp:datagrid id="DataGrid1" runat="server" Width="560px"
AutoGenerateCol umns="False" Height="106px">
<Columns>
<asp:BoundColum n Visible="False" DataField="fibe rid" ReadOnly="True"
HeaderText="Num fibre"></asp:BoundColumn >
<asp:TemplateCo lumn HeaderText="Fib re">
<ItemTemplate >
<asp:Label id=lblfibredg runat="server" Text='<%#
Container.DataI tem("namefiber" ) %>'>
</asp:Label>
</ItemTemplate>
<EditItemTempla te>
<asp:DropDownLi st id="lstdg" runat="server"> </asp:DropDownLis t>
</EditItemTemplat e>
</asp:TemplateCol umn>
<asp:BoundColum n DataField="pour centage"
HeaderText="Pou rcentage"></asp:BoundColumn >
<asp:EditComman dColumn ButtonType="Lin kButton" UpdateText="Enr egistrer
modification" HeaderText="Mod ifier la ligne"
CancelText="Ann uler" EditText="Modif ier"></asp:EditCommand Column>
<asp:ButtonColu mn Text="Supprimer " HeaderText="Sup primer la ligne"
CommandName="De lete"></asp:ButtonColum n>
</Columns>
</asp:datagrid></td></tr>
</table>
</form>

Jun 29 '06 #2

Hi Ken,
I try your code and it's working great now. Thank you

Jun 29 '06 #3

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

Similar topics

2
2523
by: news.microsoft.com | last post by:
Hi I write dll library which one of it component will be Net socket communication. Communication is working very good, but i've got problem when client is connecting. When server is started, client is connecting without problems; but when servre is down and i start client, client connect to server! Few lines from code: client.Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
0
4248
by: Tim Northrup | last post by:
Help! We have DB2 V7.2 (fixpak 12) installed on Windows2003 Server, and the latest V7.2 client installed on another system. The DB2CODEPAGE on all systems is set to 1208, and the database was created with code set UTF-8 / codepage 1208. (Note: Running our test application described below on the database host as opposed to a separate client system produced the same results as described below). When we perform an INSERT statement...
2
4672
by: Rhino | last post by:
I am trying to verify that I correctly understand something I saw in the DB2 Information Center. I am running DB2 Personal Edition V8.2.1 on Windows. I came across the following in the Info Center: To return a result set from a procedure to the originating application, use the WITH RETURN TO CLIENT clause. When WITH RETURN TO CLIENT is specified on a result set, no nested procedures can access the result set.
0
2169
by: Harley | last post by:
Hello, I am just learning the tcp/ip functions etc under vb.net so please look over me if this is obviouse. I have been all over looking into any functions that I didn't totaly understand and can't see that I am doing anything wrong (i obviousely am though) everything "works", client connects to server and when anything is sent to the server it starts the mp3 and passes all messages the way i ment for it to except that my server is...
2
1992
by: Delmar | last post by:
I need to build Web Application that will generate a client to execute some operations. Each client has running silent application. Maybe somebody can advice me what can I do ? Thank you.
2
6878
by: Macca | last post by:
My app has an asynchronous socket server. It will have 20 clients connected to the server. Each client sends data every 500 millisecondsThe Connections once established will not be closed unless there is a problem with the connection. I need to know which client has sent the incoming data as each client has its own buffer on my "server" app. I am using the standard asynch socket code from MSDN to listen for connections and they...
2
7578
by: J Huntley Palmer | last post by:
I am having a horrific time integrating uw-imap's c-client for imap support in php. The problem is a whole bunch of "Text relocation remains referenced against symbol" errors during linking. Any help appreciated! The ordeal is a follows I am using Solaris 10 with php5.1.1. GCC:
5
3445
by: Yossarian | last post by:
I have a handheld running CE .NET 4.2 and I am using c# with framework 1.1 to develop a solution for syncing data that is on the handheld with the local pc. Our handheld cradles only support network connections, no usb or serial, so i have to use networking to get the data transfered. Here's the problem. I have the server accepting connections fine, but i'm a little confused how to actually send the server data, and then how the...
2
4103
by: nsaffary | last post by:
hi I hava a client/server program that run correctly when i run it in one computer(local) but when I run client on a one computer and run server run on another, connection does not stablish.(I set server machine IP for client and server) please guide me? server : #include <winsock2.h> #include <iostream> #include <stdio.h> #include <string.h> #include <windows.h> #pragma comment(lib, "ws2_32");
4
9294
MMcCarthy
by: MMcCarthy | last post by:
http://bytes.com/images/howtos/projectscope_blocks.jpgAs a freelance IT consultant for over 10 years, I’ve come to appreciate well defined project scopes. A project scope is a common understanding between you and your client as to what work is included in, or excluded from, a project.In a study done by CA towards end of last year, one third of all projects end up over budget and over-spend typically 10-20% of the original budget. Primary reasons...
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10216
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9865
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8873
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.