confirmation pop up in editable datagrid

VBAHole22

Contributor
Joined
Oct 21, 2003
Messages
432
Location
VA
Is there a way to add a confirmation pop-up (maybe js) on an editable datagrid?
I have a datagrid that allows users to edit a field. When they click the save button in the editbuttoncolumn I would like a confirmation message to pop up so that they can reverse course if they wish.
But I can't get a handle on that save button because it isn't generated in the beginning to add script to it.
Is this possible?
 
You should be able to hook onto it from the OnItemDataBound...get the controls from that cell and check the text for 'Save' then add from there:

Visual Basic:
If e.Item.ItemType = ListItemType.EditItem Then
    For Each c As Control in e.Item.Cells(0).Controls
        If c.GetType() = GetType(LinkButton)  AndAlso _
           DirectCast(c, LinkButton).Text = "Save" Then
                DirectCast(c, LinkButton).Attributes.Add("onclick", "myJavaScriptFunctionName")
        End If
    Next
End If
If that's what you've done and .NET still hasn't rendered those link buttons yet try doing it in pre-render and going through the datagrid items collection. If remember right though what I gave you above should be close to working.
 
Back
Top