vb.net - Get ID from dynamically generated LinkButton -
i generating button dynamically in code behind , assign id database table.
dim subjectlinkbutton linkbutton = new linkbutton() subjectlinkbutton.attributes.add("id", doc.inboxid) subjectlinkbutton.text = doc.receivedsubject addhandler subjectlinkbutton.click, addressof subjectlinkbutton_click
when click on button, use
dim btn linkbutton = directcast(sender, linkbutton) me.debugtest.innertext = "button id:" & btn.id
i error: object reference not set instance of object. @ inbox.subjectlinkbutton_click(object sender, eventargs e)
changed attributes.add
subjectlinkbutton.commandname = "inbox_id" subjectlinkbutton.commandargument = doc.inboxid
and
dim btn linkbutton = directcast(sender, linkbutton) me.debugtest.innertext = "button: " & btn.commandname & " " & btn.commandargument
Comments
Post a Comment