1
Answer

ItemCreated of Datagrid using vb

Don To

Don To

17y
3.2k
1

Could someone please help?

I have a datagrid and inside it, i have a button.  I also create "ItemCreated" below for this button inside the datagrid.  But when i debug the application, i see this "ItemCreated" function run so many time over and over again.  What should i do?  I only want it run once when I click on the button inside the datagrid.  Where should i put this function?  I really appreciate your help.

Sub
dgProgram_ItemCreated(ByVal sender As Object, ByVal e As DataGridItemEventArgs) Handles dgProgram.ItemCreated

If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then

Me.program.Value = e.Item.Cells(1).Text

Dim btn As Button
btn = e.Item.Cells(14).Controls(0)

'btn.Attributes.Add("onclick", "return testing();")

End If
End sub

Answers (1)