asp.net - RadListView insertitemtemplate still showing after insert -
i have pretty simple scenario using manual data operations rad list view. insert item collection in iteminserting event, listview shows new item insertitemtemplate still showing. setup wrong? have manually hide thing?
markup
<%@ page language="vb" autoeventwireup="false" codefile="test2.aspx.vb" inherits="test2" %> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <telerik:radscriptmanager runat="server" id="rsm"></telerik:radscriptmanager> <div> <telerik:radlistview id="rlv" runat="server" datakeynames="userid" itemplaceholderid="itemplaceholder" height="400px" allowpaging="true"> <insertitemtemplate> <tr> <td> <div style="vertical-align: middle; white-space: nowrap;"> <asp:linkbutton id="btninsert2" runat="server" text="insert" commandname='<%# telerik.web.ui.radlistview.performinsertcommandname %>'></asp:linkbutton> <asp:linkbutton id="btncancel2" runat="server" text="cancel" commandname='<%# telerik.web.ui.radlistview.cancelcommandname %>'></asp:linkbutton> </div> </td> <td> <div style="vertical-align: middle; white-space: nowrap;"> <telerik:radcombobox id="radcombobox1" runat="server" autopostback="true" causesvalidation="false" allowcustomtext="true" backcolor="white" emptymessage="select person" enableloadondemand="true" showmoreresultsbox="true" width="150px" dropdownwidth="200px" zindex="9002" enablescreenboundarydetection="false" style="margin-bottom: 0px" datatextfield="username" datavaluefield="pkuserid" filter="contains" onitemsrequested="rcb_itemsrequested"> <collapseanimation duration="200" type="outquint" /> </telerik:radcombobox> </div> </td> </tr> </insertitemtemplate> <itemtemplate> <tr> <td> <asp:literal id="lname" runat="server" text='<%# eval("username") %>'></asp:literal> </td> </tr> </itemtemplate> <layouttemplate> <asp:linkbutton id="btninsert" runat="server" causesvalidation="false" commandname='<%# telerik.web.ui.radlistview.initinsertcommandname %>' text="add user" /> <table> <tr> <td style="border: ridge 1px lightgray"> <strong>applicable users</strong> <table> <asp:placeholder runat="server" id="itemplaceholder"></asp:placeholder> </table> </td> </tr> </table> </layouttemplate> </telerik:radlistview> </div> </form> </body> </html>
code behind
partial class test2 inherits system.web.ui.page public property users ilist(of userinfo) return if(viewstate("users"), new list(of userinfo)) end set(byval value ilist(of userinfo)) viewstate("users") = value end set end property protected sub page_load(byval sender object, byval e system.eventargs) handles me.load if not page.ispostback me.users = getinitialusers() end if rlv.datasource = users rlv.databind() me.viewstate.setitemdirty("users", true) end sub private function getinitialusers() ilist(of userinfo) dim users new list(of userinfo) users.add(new userinfo(1, "1")) users.add(new userinfo(2, "2")) users.add(new userinfo(3, "2")) users.add(new userinfo(4, "4")) return users end function protected sub rcb_itemsrequested(byval sender object, byval e telerik.web.ui.radcomboboxitemsrequestedeventargs) dim combobox telerik.web.ui.radcombobox = sender dim itemoffset integer = e.numberofitems dim numberofitems integer = 1000000000 dim take integer = 20 integer = 0 take combobox.items.add(new telerik.web.ui.radcomboboxitem(i + itemoffset, (i + itemoffset).tostring)) next dim numberofitemsincombobox integer = e.numberofitems + combobox.items.count if numberofitems > 0 e.message = [string].format("items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", numberofitemsincombobox, numberofitems) else e.message = "no matches" end if e.endofitems = (numberofitemsincombobox >= numberofitems) end sub protected sub rlv_iteminserting(byval sender object, byval e telerik.web.ui.radlistviewcommandeventargs) handles rlv.iteminserting dim combobox telerik.web.ui.radcombobox = e.listviewitem.findcontrol("radcombobox1") if not string.isnullorwhitespace(combobox.selectedvalue) dim userid integer = combobox.selectedvalue dim username string = combobox.text me.users.add(new userinfo(userid, username)) else e.canceled = true end if end sub <serializable()> public class userinfo private _userid integer private _username string public readonly property userid integer return _userid end end property public readonly property username string return _username end end property public sub new(byval userid integer, byval username string) _userid = userid _username = username end sub end class end class
after have inserted new item, set insertitemposition
none
:
radlistview1.insertitemposition = radlistviewinsertitemposition.none
Comments
Post a Comment