asp.net - change the text of two labels based on the selected row of a gridview -
i want change text of 2 labels based on selected row of gridview.
i keep getting error says public member row not exist on linkbutton
protected sub linkbutton1_click(byval sender object, byval e system.eventargs) dim linkbutton1 linkbutton = directcast(sender, linkbutton) dim tour label = ctype(sender.row.findcontrol("label2"), label) dim depart label = ctype(sender.row.findcontrol("label3"), label) test.text = tour.text test1.text = depart.text updatepanel9.update() end sub
according code, sender
linkbutton
. property row
won't exist on link button when reference sender.row
. that's why error.
you want hook selectedindexchanged event, give access row more easily.
sub mygridview_selectedindexchanged(byval sender object, byval e eventargs) dim mygrid gridview = trycast(sender, gridview) dim selectedrow gridviewrow = mygrid.selectedrow 'do selected row needed here..... end sub
Comments
Post a Comment