asp.net - Prevent GridView Cell CssClass from overriding the ItemStyle-CssClass -
i've got checkboxlist
names of gridview
columns. when check or uncheck box, triggers postback , show_hide_columns sub
(shown below). cycles through list , applies "shown
" css
appropriate columns headerstyle
, itemstyle
.
that's working fine.
during gridview's rowdatabound
, check see if "scheduled pick" field not equal "max_schedule_pick
" field. if that's true, set cell's cssclass
"scheduled_pick_out_of_sync
".
that had been working rather well, too.
here's problem: when have un-checked scheduled pick column (which should apply "hidden" headerstyle.cssclass
, itemstyle.cssclass
), appropriate scheduled pick cell still gets "scheduled_pick_out_of_sync
" cssclass. result hidden header of cells visible , colored. don't want of them shown @ when column supposed hidden.
below, you'll find code. sure appreciate guys give me keep rowdatabound
applying cssclass cell when column hidden.
thanks,
rob
code behind
protected sub page_load(byval sender object, byval e system.eventargs) handles me.load if not ispostback 'alert_label.text = "not postback" else 'alert_label.text = "postback" end if ' shows , hides columns via css every time page loaded. checkboxlist triggers autopostback each click. common_functions.show_hide_columns(gv_allocation, list_of_columns) end sub sub gv_allocation_conditional_formatting(byval sender object, byval e gridviewroweventargs) handles gv_allocation.rowdatabound dim gv_columns datacontrolfieldcollection = sender.columns dim gv_e gridviewroweventargs = e if e.row.rowtype = datacontrolrowtype.datarow ' working fine when column "shown" if gv_e.row.cells(common_functions.findcolumn(gv_columns, "max_scheduled_pick")).text <> _ gv_e.row.cells(common_functions.findcolumn(gv_columns, "scheduled pick")).text gv_e.row.cells(common_functions.findcolumn(gv_columns, "scheduled pick")).cssclass = "scheduled_pick_out_of_sync" end if ' 1 works same 1 above, don't want engage if column hidden 'if gv_e.row.cells(common_functions.findcolumn(gv_columns, "max_scheduled_pick")).text <> _ 'gv_e.row.cells(common_functions.findcolumn(gv_columns, "scheduled pick")).text _ 'and gv_columns(common_functions.findcolumn(gv_columns, "scheduled pick")).itemstyle.cssclass = "shown" 'gv_e.row.cells(common_functions.findcolumn(gv_columns, "scheduled pick")).cssclass = "scheduled_pick_out_of_sync" 'end if end if end sub public shared sub show_hide_columns(byval gv_name gridview, byval columnlist checkboxlist) each li listitem in columnlist.items if li.selected gv_name.columns(common_functions.findcolumn(gv_name.columns, li.value.tostring)).headerstyle.cssclass = "shown" gv_name.columns(common_functions.findcolumn(gv_name.columns, li.value.tostring)).itemstyle.cssclass = "shown" else gv_name.columns(common_functions.findcolumn(gv_name.columns, li.value.tostring)).headerstyle.cssclass = "hidden" gv_name.columns(common_functions.findcolumn(gv_name.columns, li.value.tostring)).itemstyle.cssclass = "hidden" end if next end sub
Comments
Post a Comment