Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

Wanna-Be C# Superstar
Posted

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:

 

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...