How to diable buttoncolumn's

P

Philip Yeo

Just a question,

If I have a column that performs delete. But I want to disable all the
delete buttons in this column when user click's on edit,

I put this code here,

Protected sub mydatagrid_edit(sender as object, e as
datagridcommandeventargs)

mydatagrid.edititemindex = cint(e.item.itemindex)
' because it is in the 2nd col item's integer parameter is 1
dim btnDel as button = e.item(1).controls(0)
btnDel.enable = false
loaddata()

end sub

However this doesn't work.
So I figured that it could be because there's a whole row of the table that
has this button so the controls(0) is actually returning an array object.

Thus would it be wise to write the code this way. Pls advice if there's any
mistake

Protected sub mydatagrid_edit(sender as object, e as
datagridcommandeventargs)

mydatagrid.edititemindex = cint(e.item.itemindex)
' because it is in the 2nd col item's integer parameter is 1
dim btnDel() as button = e.item(1).controls(0)
dim i as integer
for i = 0 to btnDel.count
btnDel(i).enable = false
next i
loaddata()

end sub
 
S

Stevie_mac

Just a theory but... does your loaddata() function rebind the grid? If so, then
put the btnDel.enable = false after loaddata()
 
S

Stevie_mac

So your sorted now! Right?
you did try putting the btnDel.enable = false after loaddata()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top