meenakshidhar
Programmer
Hi,
I want to display the confirmation message before deleting any record from datagrid...
HTML Code--
__________________________________________________________
<ASP
ATAGRID id="DataGrid1"
runat="server"
CellPadding="3"
BorderWidth="1px"
AutoGenerateColumns="False"
OnDeleteCommand="DataGrid1_Delete"
OnEditCommand="DataGrid1_Edit"
OnItemDataBound="DataGrid1_ItemDataBound"
OnSortCommand="SortCommand_Click"
AllowSorting="True"
PageSize="10"
OnPageIndexChanged="PageIndexChanged_OnClick"
AllowPaging="True">
<Columns>
<asp:BoundColumn visible="false" DataField="LOCATION_ID">
</asp:BoundColumn>
<asp:BoundColumn SortExpression="COMPANY_NAME" DataField="COMPANY_NAME" HeaderText="Company Name">
</asp:BoundColumn>
</Columns>
<Columns>
<asp:EditCommandColumn EditText="Edit Info" ButtonType="PushButton" UpdateText="Update" CancelText="Cancel">
</asp:EditCommandColumn>
</Columns>
<Columns>
<asp:ButtonColumn Text="Delete" ButtonType="PushButton" CommandName="delete"></asp:ButtonColumn>
</Columns>
</ASP
ATAGRID>
_________________________________________________________
ASP Code--
_________________________________________________________
Sub DataGrid1_Delete(ByVal s As Object, ByVal e As DataGridCommandEventArgs)
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
e.Item.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this item?');")
End If
Dim intLocID As Integer = e.Item.Cells(0).Text.Trim
'the above code is not wrking properly..i.e. after seleceting delete button twice then only this confirmation box appears...and next issue is that after clicking 'Ok', only then the below code shld be executed...if User selects 'cancel' then below code shld not be executed...
Dim MyConnection As SqlConnection
Dim MyCommand As SqlDataAdapter
Dim DS As DataSet
MyConnection = New SqlConnection("Data Source=INFO3783;" _
& "Initial Catalog=GTD_Test;User Id=gtd;Password=gtd;" _
& "Connect Timeout=15;Network Library=dbmssocn;")
MyCommand = New SqlDataAdapter(Delete from GTD_M_ORG where LOCATION_ID=intLocID", MyConnection)
DS = New DataSet()
MyCommand.Fill(DS)
End Sub
__________________________________________________________
Urgent Help needed..
Regards,
Meenakshi Dhar
I want to display the confirmation message before deleting any record from datagrid...
HTML Code--
__________________________________________________________
<ASP
runat="server"
CellPadding="3"
BorderWidth="1px"
AutoGenerateColumns="False"
OnDeleteCommand="DataGrid1_Delete"
OnEditCommand="DataGrid1_Edit"
OnItemDataBound="DataGrid1_ItemDataBound"
OnSortCommand="SortCommand_Click"
AllowSorting="True"
PageSize="10"
OnPageIndexChanged="PageIndexChanged_OnClick"
AllowPaging="True">
<Columns>
<asp:BoundColumn visible="false" DataField="LOCATION_ID">
</asp:BoundColumn>
<asp:BoundColumn SortExpression="COMPANY_NAME" DataField="COMPANY_NAME" HeaderText="Company Name">
</asp:BoundColumn>
</Columns>
<Columns>
<asp:EditCommandColumn EditText="Edit Info" ButtonType="PushButton" UpdateText="Update" CancelText="Cancel">
</asp:EditCommandColumn>
</Columns>
<Columns>
<asp:ButtonColumn Text="Delete" ButtonType="PushButton" CommandName="delete"></asp:ButtonColumn>
</Columns>
</ASP
_________________________________________________________
ASP Code--
_________________________________________________________
Sub DataGrid1_Delete(ByVal s As Object, ByVal e As DataGridCommandEventArgs)
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
e.Item.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this item?');")
End If
Dim intLocID As Integer = e.Item.Cells(0).Text.Trim
'the above code is not wrking properly..i.e. after seleceting delete button twice then only this confirmation box appears...and next issue is that after clicking 'Ok', only then the below code shld be executed...if User selects 'cancel' then below code shld not be executed...
Dim MyConnection As SqlConnection
Dim MyCommand As SqlDataAdapter
Dim DS As DataSet
MyConnection = New SqlConnection("Data Source=INFO3783;" _
& "Initial Catalog=GTD_Test;User Id=gtd;Password=gtd;" _
& "Connect Timeout=15;Network Library=dbmssocn;")
MyCommand = New SqlDataAdapter(Delete from GTD_M_ORG where LOCATION_ID=intLocID", MyConnection)
DS = New DataSet()
MyCommand.Fill(DS)
End Sub
__________________________________________________________
Urgent Help needed..
Regards,
Meenakshi Dhar