vb.net - How to parse a string value out of a RadGrid cell for use in RadGrid PreRender event? -


i have radgrid:

 <telerik:radgrid id="rgvboards" runat="server" allowpaging="true" allowsorting="true" grouppanelposition="top"                              onprerender="rgvboards_prerender" datasourceid="odsboard">                             <groupingsettings casesensitive="false"></groupingsettings>                             <mastertableview autogeneratecolumns="false" datakeynames="boardid" datasourceid="odsboard" allowfilteringbycolumn="true" showfooter="true">                                 <columns>                                                                                                                <telerik:gridbuttoncolumn uniquename="inactivate" buttontype="imagebutton" imageurl="../images/canceldelete.gif"                                          commandname="inactivate" display="true">                                     </telerik:gridbuttoncolumn>                                     <telerik:gridbuttoncolumn uniquename="activate" buttontype="imagebutton" imageurl="../images/greencheck.png"                                         commandname="inactivate" display="true">                                     </telerik:gridbuttoncolumn>                                                                                 <telerik:gridboundcolumn datafield="boardstatus" allowfiltering="false" headertext="status"                                          uniquename="boardstatus">                                     </telerik:gridboundcolumn>                                 </columns>                                 <pagerstyle alwaysvisible="true" pagesizes="10;20;30;999" />                             </mastertableview>                         </telerik:radgrid> 

the goal 1 button displayed per row. when status marked active ("a") "inactivate" button display.

i have been trying use prerender event make happen. know prerender event being read , has affect on grid because without applying logic read boardstatus column can control buttons display:

    protected sub rgvboards_prerender(byval sender object, byval e eventargs)             rgvboards.mastertableview.getcolumn("inactivate").display = false             rgvboards.mastertableview.getcolumn("activate").display = false     end sub 

i have tried quite few of suggestions telerik forums , documentation such as:

    protected sub rgvboards_prerender(byval sender object, byval e eventargs)         dim dataitem griddataitem = trycast(e.item, griddataitem)         dim itemvalue string = dataitem("boardstatus").text          if itemvalue.equals("a")             rgvboards.mastertableview.getcolumn("inactivate").display = false         elseif itemvalue.equals("i")             rgvboards.mastertableview.getcolumn("activate").display = false         end if     end sub 

which produces problem 'item' not member of 'system.eventargs'.

what proper way read radgrid cell , put in string variable?

the proper way using 'onneeddatasource' event.
html:

<telerik:radgrid id="rgvboards" runat="server" allowpaging="true" allowsorting="true" grouppanelposition="top"                               onneeddatasource="rgvboards_needdatasource" datasourceid="odsboard">                             <groupingsettings casesensitive="false"></groupingsettings>                             <mastertableview autogeneratecolumns="false" datakeynames="boardid" datasourceid="odsboard" allowfilteringbycolumn="true" showfooter="true">                                 <columns>                                                                         <telerik:gridtemplatecolumn uniquename="imagebuttoncolumn">                                         <itemtemplate>                                              <asp:imagebutton id="imagebutton1" runat="server" imageurl="../images/canceldelete.gif"                                             commandname="inactivate" visible='<%# eval("boardstatus").equals("a")%>'                                             alternatetext="inactivate" />                                              <asp:imagebutton id="imagebutton2" runat="server" imageurl="../images/greencheck.png"                                             commandname="activate" visible='<%# eval("boardstatus").equals("i")%>'                                             alternatetext="activate" />                                          </itemtemplate>                                     </telerik:gridtemplatecolumn>                                     <telerik:gridboundcolumn datafield="boardstatus" allowfiltering="false" headertext="status"                                          uniquename="boardstatus" datatype="system.string">                                     </telerik:gridboundcolumn>                                 </columns>                                 <pagerstyle alwaysvisible="true" pagesizes="10;20;30;999" />                             </mastertableview>                         </telerik:radgrid>                  

along on end (vb):

protected sub rgvboards_needdatasource(sender object, e gridneeddatasourceeventargs)         rgvboards.datasource = getgridsource()     end sub      private function getgridsource() datatable         dim datatable new datatable()          column = new datacolumn()         column.datatype = type.[gettype]("system.string")         column.columnname = "boardstatus"         datatable.columns.add(column)          dim primarykeycolumns datacolumn() = new datacolumn(0) {}         primarykeycolumns(0) = datatable.columns("boardid")         datatable.primarykey = primarykeycolumns          return datatable     end function 

has allowed me have radgrid render proper image button using board status deciding factor.

source: http://www.telerik.com/help/aspnet-ajax/grid-advanced-data-binding.html


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -