Click here to Skip to main content
15,909,539 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello sir,

I am using a datalist to show the business information of a user. I have delete label in datalist. when user click the delete label then the delete conformation box appear. if user click delete then that item will be deleted. cancel means that box must be discarded... How can i do that....?
Posted

DialogResult result = MessageBox.Show( "Do you want to delete the selected the item?.", "Confirm Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1 );

if( result == DialogResult.OK )
{
//delete the data
}
else
{
//do not delete
}
 
Share this answer
 
Comments
SnvMohan 12-Mar-13 5:40am    
I am creating a web application project... i thing this answer working on windows application ...... So please help me for that..?
DialogResult result = MessageBox.Show( "Do you want to delete the selected the item?.", "Confirm Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1 );

if( result == DialogResult.OK )
{
//delete the data
}
else
{
//do not delete
}
 
Share this answer
 
DialogResult result = MessageBox.Show( "Do you want to delete the selected the item?.", "Confirm Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1 );

if( result == DialogResult.OK )
{
//delete the data
}
else
{
//do not delete
}
 
Share this answer
 
Hi, How are you calling a OnClick() event on the label which you have?
There is no pre-defined OnClick() event for a label. You can add an attribute as shown below for your label, but then the function which is called on the OnClick() event should be a Javascript one. Then migrating back to the server-side code to delete something will be a tedious task.

C#
MyLabel.Attributes.Add("OnClick", "CallMe();");


In my opinion, why don't you use a button to delete whatever you want to delete.
Call a event handler on the button click and then have a confirmation message box(It will also be a Javascript call) to intimate the user that "Are you sure you wana delete?". If yes, then call again a function which will actually delete stuff from your dataset.

Hope it helps.


-Anurag
 
Share this answer
 
Comments
SnvMohan 12-Mar-13 5:43am    
Thank u sir ..... i need that coding to understand... so would u post that code for aspx file and aspx.cs file...Please sir
Anurag Sinha V 12-Mar-13 7:09am    
Hi, give me some time buddy..am in office..will post the code in a while...

-anurag

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900