asp.net - How to get the value of a RadGrid selected row during PostBack -
i'm working radgrid programmatically defined , populated @ runtime. elsewhere on page (within same radajaxpanel) control has data populated id passed radgrid. when row in radgrid selected, passes id control. problem grid_selectedindexchanged event doesn't occur until after postback completed, , control needs id data during postback.
related issue (i'm sure have same problem @ core) issue i'm having deleting records. have button when clicked, marks record deleted in database. since needs id of selected row(s) radgrid, fails work.
any solutions? i've been scouring web solutions week no results.
this project convoluted, here's of relevant code:
private sub page_load(byval sender object, byval e system.eventargs) handles me.load definegrid() _grid.datasource = buildmaindataset() _grid.databind() if _grid isnot nothing andalso _grid.selecteditems.count > 0 dim selectedrow griddataitem selectedrow = _grid.selecteditems(0) ctrl.id = selectedrow("id").text end if end sub private sub grid_selectedindexchanged(sender object, e system.eventargs) if _grid.selecteditems.count > 0 dim selectedrow griddataitem selectedrow = _grid.selecteditems(0) ctrl.id = selectedrow("id").text end if end sub
and control:
public property id integer? if _id <> 0 return _id else return nothing end if end set(value integer?) if value <> id orelse value <> _id _id = value end if end set end property protected sub page_load(byval sender object, byval e system.eventargs) handles me.load loaddropdownlist(_id) 'populates dropdownlist data database id end sub
i've set breakpoint on control's page_load()
, found on first load, id 0. on subsequent loads (after gridrow has been selected), id expected value, issue contents of dropdownlist overwritten on every load, instead of retaining selection. , adding ispostback
check means dropdownlist never loaded (the id 0 when loaddropdownlist()
called).
Comments
Post a Comment