Template Column in DataGrid and Button
Dear All,
I have a Template Column in my DataGrid with a LinkButton in it. I would like to delete one row with a confirmation on delete.
I have declared a LinkButton in my datagrid and in DataGrid1_ItemCreated I am adding a Javascript confirm code to linkButton's attribute. It works fine and I get the Confirmation and when I press on OK in goes to btnlinkDelete_Click sub nicely,
Here is my problem, I want to find out which row has been click to delete and I am using the following code to find out the DataGridItem:
Public Sub btnlinkDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlinkDelete.Click
Dim myBtnDelete As LinkButton = CType(DataGrid1.FindControl("btnlinkDelete"), LinkButton)
If Not myBtnDelete Is Nothing Then
Dim objDataGridItem As DataGridItem = CType(myBtnDelete.Parent.Parent, DataGridItem)
Dim subcatid_value As Integer = DataGrid1.DataKeys.Item(objDataGridItem.ItemIndex)
End If
End Sub
The first line of this function always returns NOTHING,
and that's why i can not find the DataGridItem to be able to find the DataKey
Please help me, I need this very soon,
Thanks very much indeed in advance
Behnam
|