how to prompt user if they try to delete wrong value

liunx

Guest
How to prompt user if they try to delete a record from datagrid which
has relationship with other table? I created a editable datagrid and
want to inform user if they try to delete a record that has reletions with other tables. I be happy if some one help me how i can do this in asp.net .Thanks

<!-- m --><a class="postlink" href="http://i5.photobucket.com/albums/y180/method007/19932c0e.jpg">http://i5.photobucket.com/albums/y180/m ... 932c0e.jpg</a><!-- m --> (db reletion ship)

Here is my delete code :


Private Sub DataGridMatch_DeleteCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGridPlayer.DeleteCommand
[t][t]Dim MyCommand As SqlCommand
[t][t]Dim DeleteCmd As String = "Delete From players Where playerno = " & e.Item.Cells(2).Text
[t][t]MyCommand = New SqlCommand(DeleteCmd, MyConnection)
[t][t]MyCommand.Connection.Open()
[t][t]MyCommand.ExecuteNonQuery()
[t][t]MyCommand.Connection.Close()
[t][t]DataGridPlayer.EditItemIndex = -1
[t][t]BindDataGridPlayer()


[t]End SubWhy don't you set up your code to not allow the delete button to even be there so the users can not delete it in the first place?

EricWhy don't you set up your code to not allow the delete button to even be there so the users can not delete it in the first place?

Eric

well for example in palyers table i want to be able to delete some records from datagrid that has no coresponding values in other tables such as penalites.That is why i do not want to remove the delete button completly!What I was saying is that I would try to figure out a way to only show the delete button for those that need it and hide it for the ones that can not be deleted. It can be done with a template column.

EricWhat I was saying is that I would try to figure out a way to only show the delete button for those that need it and hide it for the ones that can not be deleted. It can be done with a template column.

Eric

Well i am new to asp.net world. Now i use editable datagrid to update/delete records in my db. but i do not know how i can add such intelegence that u mentioned in to my datagrid. is there any example some where in the net that i have a look at.Thanks
 
Back
Top