Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Im adding datagrids dinamically into a page, so I have to do everything in the codebehind.

The problem is that I cant add the event handler for the EditCommand button

 

Heres some code

Dim colEdit As New WebControls.EditCommandColumn()

           colEdit.CancelText = "Cancelar"
           colEdit.UpdateText = "OK"
           colEdit.EditText = "Editar"
           colEdit.ButtonType = ButtonColumnType.LinkButton

           dg.Columns.Add(colEdit)

AddHandler dg.EditCommand, New DataGridCommandEventHandler(AddressOf dg_EditCommand)

 

I can make the ItemDataBound event bubble, but the EditCommand isnt working.

 

Any help would be appreciated!

 

Thanks

Posted

I forgot to mention the Edit method im using to try to catch the event:

 

Public Sub dg_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs)

        CType(source, DataGrid).EditItemIndex = e.Item.ItemIndex

   End Sub

  • *Experts*
Posted

What you're doing in VB is the same as that C# code. The only

difference is the placement of the code. You need to place your

code in the InitializeComponent method of the codebehind page,

not in Page_Load (as I'm assuming that's where it is ATM).

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Posted

i dont know if the syntax of the addhandler is correct i usually write

AddHandler dg.EditCommand, AddressOf dg_EditCommand

instead of

AddHandler dg.EditCommand, New DataGridCommandEventHandler(AddressOf dg_EditCommand)

i hope this helps

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...