The problem I am having is that whenever I delete an item from my datagrid the datagrid does not refresh itself. I have the delete linkbutton in the last column which is a template column. The page functions appropriately and deletes the record, but I cannot get it to update the page. I tried placing mydatagrid.databind() within the delete section of the code, but that did not work. Here is what I have:
<script>
function getconfirm()
{
if (confirm("WARNING! You are about to delete a project. Are you sure you wish to proceed?")
return true;
else
return false;
}
</script>
<asp:datagrid id="ProjDataGrid" runat="server" enableviewstate="False" AutoGenerateColumns="False" AllowSorting="True" BorderColor="White" GridLines="None" CellPadding="2" CellSpacing="1" Width="100%">
<Columns>
<asp:TemplateColumn HeaderText="Options">
<ItemTemplate>
<asp:LinkButton id="cmdDel" onclick="delete_click" runat="server" Text="Delete" CommandName="Delete" CausesValidation="false"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
'DataGrid Delete LinkButton Functionality
Private Sub ProjDataGrid_ItemDataBound(ByVal sender As Object, ByVal e As DataGridItemEventArgs) Handles ProjDataGrid.ItemDataBound
Dim l As LinkButton
Dim h As HyperLink
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
l = CType(e.Item.Cells(2).FindControl("cmdDel", LinkButton)
l.Attributes.Add("onclick", "return getconfirm();"
l.ID = "d" & DataBinder.Eval(e.Item.DataItem, "prID"
h = CType(e.Item.Cells(2).FindControl("EditLink", HyperLink)
h.NavigateUrl = h.NavigateUrl & "&prID=" & DataBinder.Eval(e.Item.DataItem, "prID" & "&clID=" & DataBinder.Eval(e.Item.DataItem, "clID"
End If
End Sub
'DataGrid Delete LinkButton Functionality
Sub delete_click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim link As LinkButton = CType(sender, LinkButton)
Dim da As New ReviewDAC.DataAccess()
da.DeleteProject(CInt(Right(link.ID, Len(link.ID) - 1)))
End Sub
Thank you very much for your help!!!!! RSchultz
rschultz@fivestardev.com
**Access 2000**
<script>
function getconfirm()
{
if (confirm("WARNING! You are about to delete a project. Are you sure you wish to proceed?")
return true;
else
return false;
}
</script>
<asp:datagrid id="ProjDataGrid" runat="server" enableviewstate="False" AutoGenerateColumns="False" AllowSorting="True" BorderColor="White" GridLines="None" CellPadding="2" CellSpacing="1" Width="100%">
<Columns>
<asp:TemplateColumn HeaderText="Options">
<ItemTemplate>
<asp:LinkButton id="cmdDel" onclick="delete_click" runat="server" Text="Delete" CommandName="Delete" CausesValidation="false"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
'DataGrid Delete LinkButton Functionality
Private Sub ProjDataGrid_ItemDataBound(ByVal sender As Object, ByVal e As DataGridItemEventArgs) Handles ProjDataGrid.ItemDataBound
Dim l As LinkButton
Dim h As HyperLink
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
l = CType(e.Item.Cells(2).FindControl("cmdDel", LinkButton)
l.Attributes.Add("onclick", "return getconfirm();"
l.ID = "d" & DataBinder.Eval(e.Item.DataItem, "prID"
h = CType(e.Item.Cells(2).FindControl("EditLink", HyperLink)
h.NavigateUrl = h.NavigateUrl & "&prID=" & DataBinder.Eval(e.Item.DataItem, "prID" & "&clID=" & DataBinder.Eval(e.Item.DataItem, "clID"
End If
End Sub
'DataGrid Delete LinkButton Functionality
Sub delete_click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim link As LinkButton = CType(sender, LinkButton)
Dim da As New ReviewDAC.DataAccess()
da.DeleteProject(CInt(Right(link.ID, Len(link.ID) - 1)))
End Sub
Thank you very much for your help!!!!! RSchultz
rschultz@fivestardev.com
**Access 2000**