asp.net - Combobox databind from string not working -
in application, pop radwindow when user add/edit record.
i had use ondatabound function combox, code not working.
<%@ page language="vb" autoeventwireup="false" codefile="allowance.aspx.vb" inherits="payroll_allowance" %> <%@ register assembly="telerik.web.ui" namespace="telerik.web.ui" tagprefix="telerik" %> <!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 id="head1" runat="server"> <title>edit payroll allowance</title> </head> <body> <form id="form1" runat="server"> <telerik:radscriptmanager id="radscriptmanager1" runat="server"> </telerik:radscriptmanager> <telerik:radsplitter id="radsplitter1" runat="server" width="100%" height="100%" orientation="horizontal"> <telerik:radpane id="rpcontent" runat="server"> <asp:panel id="panel1" runat="server" width="100%" cssclass=thepanel> <asp:table id="table0" runat="server" height="100%"> <asp:tablerow> <asp:tablecell font-bold="true" font-size="10pt" cssclass=thehead> payroll allowance </asp:tablecell> </asp:tablerow> </asp:table> </asp:panel> <telerik:radtoolbar id="rtbmain" runat="server" width="100%"> <items> <telerik:radtoolbarbutton width="80px" value="add" text="add" causesvalidation="false"></telerik:radtoolbarbutton> <telerik:radtoolbarbutton isseparator="true"></telerik:radtoolbarbutton> <%-- <telerik:radtoolbarbutton width="80px" value="edit" text="edit" causesvalidation="false" enabled=false></telerik:radtoolbarbutton> <telerik:radtoolbarbutton isseparator="true"></telerik:radtoolbarbutton> <telerik:radtoolbarbutton width="80px" value="delete" text="delete" causesvalidation="false" enabled=false></telerik:radtoolbarbutton> <telerik:radtoolbarbutton isseparator="true"></telerik:radtoolbarbutton> --%> <telerik:radtoolbarbutton width="80px" value="report" text="report" visible=false causesvalidation="false"></telerik:radtoolbarbutton> <telerik:radtoolbarbutton isseparator="true"></telerik:radtoolbarbutton> </items> </telerik:radtoolbar> <div id="printarea"> <asp:table id="tblhistory" width=800px runat="server" > <asp:tablerow> <asp:tablecell> <asp:table id="table1" runat="server" width=650 borderstyle=none> <asp:tablerow> <asp:tablecell cssclass=fieldheader width=150>staff name</asp:tablecell> <asp:tablecell width=250><asp:label id="lbstaffname" runat=server></asp:label></asp:tablecell> <asp:tablecell cssclass=fieldheader width=150>staff no.</asp:tablecell> <asp:tablecell width=250><asp:label id="lbstaffno" runat=server></asp:label></asp:tablecell> </asp:tablerow> </asp:table> </asp:tablecell> </asp:tablerow> </asp:table> <br /> <telerik:radgrid id="rgallowance" runat="server" datasourceid="ldsallowance" gridlines="none" width="800px" allowsorting="true" autogeneratecolumns="false" allowfilteringbycolumn="false" showgrouppanel=false showfooter="false" allowpaging="true" pagesize="15"> <pagerstyle position="topandbottom" /> <clientsettings enablepostbackonrowclick="true" allowcolumnsreorder="true" allowdragtogroup="false" reordercolumnsonclient="true"> <selecting allowrowselect="true" /> </clientsettings> <mastertableview datasourceid="ldsallowance" datakeynames="allowanceid" > <commanditemsettings exporttopdftext="export pdf"></commanditemsettings> <rowindicatorcolumn> <headerstyle width="10px"></headerstyle> </rowindicatorcolumn> <expandcollapsecolumn> <headerstyle width="10px"></headerstyle> </expandcollapsecolumn> <columns> <telerik:gridboundcolumn datafield="allowanceid" headertext="allowance id" readonly="true" sortexpression="allowanceid" uniquename="allowanceid" visible=false> </telerik:gridboundcolumn> <telerik:gridboundcolumn datafield="ppscompanycode" headertext="allowance code" readonly="true" sortexpression="ppscompanycode" uniquename="ppscompanycode"><itemstyle font-underline="true" backcolor=white forecolor="blue" bordercolor=activeborder/> </telerik:gridboundcolumn> <telerik:gridboundcolumn datafield="entitlefrom" headertext="entitle from" readonly="true" dataformatstring="{0:dd-mmm-yyyy}" sortexpression="entitlefrom" uniquename="entitlefrom"><itemstyle backcolor=white bordercolor=activeborder /> </telerik:gridboundcolumn> <telerik:gridboundcolumn datafield="entitleto" headertext="entitle to" readonly="true" dataformatstring="{0:dd-mmm-yyyy}" sortexpression="entitleto" uniquename="entitleto"><itemstyle backcolor=white bordercolor=activeborder/> </telerik:gridboundcolumn> <telerik:gridboundcolumn datafield="allowanceamount" headertext="remarks" readonly="true" dataformatstring="{0:n}" sortexpression="allowanceamount" uniquename="allowanceamount"><itemstyle backcolor=white bordercolor=activeborder/> </telerik:gridboundcolumn> </columns> </mastertableview> </telerik:radgrid> </div> </telerik:radpane> </telerik:radsplitter> <telerik:radwindow id="radwindow1" runat="server" width="580px" height="300px" behaviors="close" title="add/modify payroll allowance" > <contenttemplate> <asp:table id="table2" runat="server" width="100%" height="100%"> <asp:tablerow > <asp:tablecell cssclass="editheader">allowance code: </asp:tablecell> <asp:tablecell> <telerik:radcombobox id="dfallowancecode" runat="server" width="250px" appenddatabounditems="true" autopostback="true" datatextfield="acode" ondatabound="dfallowancecode_databound"> <items> <telerik:radcomboboxitem text="--select--" value="" /> </items> </telerik:radcombobox> </asp:tablecell> </asp:tablerow> <asp:tablerow> <asp:tablecell cssclass="editheader">entitle from: </asp:tablecell> <asp:tablecell> <asp:hiddenfield id="dfallowanceid" value="0" runat="server" /> <telerik:raddatepicker id="dfstartdate" runat="server" width="150px" dateinput-dateformat="dd-mmm-yyyy" enabled="true"> </telerik:raddatepicker> <asp:requiredfieldvalidator id="requiredfieldvalidator1" runat="server" errormessage="* required" controltovalidate="dfstartdate"></asp:requiredfieldvalidator> </asp:tablecell> </asp:tablerow> <asp:tablerow> <asp:tablecell cssclass="editheader">entitle to: </asp:tablecell> <asp:tablecell> <telerik:raddatepicker id="dfenddate" runat="server" width="150px" dateinput-dateformat="dd-mmm-yyyy" enabled="true"> </telerik:raddatepicker> <asp:requiredfieldvalidator id="requiredfieldvalidator2" runat="server" errormessage="* required" controltovalidate="dfenddate"></asp:requiredfieldvalidator> </asp:tablecell> </asp:tablerow> <asp:tablerow> <asp:tablecell cssclass="editheader">amount: </asp:tablecell> <asp:tablecell> <telerik:radnumerictextbox id="dfamount" runat="server" width="125px" enabled="true" numberformat-decimaldigits="2" > </telerik:radnumerictextbox > <asp:requiredfieldvalidator id="requiredfieldvalidator3" runat="server" errormessage="* required" controltovalidate="dfamount"></asp:requiredfieldvalidator> </asp:tablecell> </asp:tablerow> <asp:tablerow> <asp:tablecell backcolor="#eeeeee" columnspan="2" horizontalalign="center"> <asp:button id="btnsave" runat="server" text="save" width="80px" /> <asp:button id="btndelete" runat="server" text="delete" width="80px" causesvalidation="false" /> <asp:button id="btncancel" runat="server" text="close" width="80px" causesvalidation="false" /> </asp:tablecell> </asp:tablerow> </asp:table> </contenttemplate> </telerik:radwindow> <asp:linqdatasource id="ldsallowance" runat="server" contexttypename="dchrisdatacontext" orderby="entitlefrom desc,allowanceid desc" tablename="hris_ppsallowances" where="sid==@sid"> <whereparameters> <asp:querystringparameter defaultvalue="0" name="sid" querystringfield="sid" type="int32" /> </whereparameters> </asp:linqdatasource> </form> </body> </html>
code behind:
protected sub dfallowancecode_databound(byval sender object, byval e telerik.web.ui.radcomboboxitemeventargs) handles dfallowancecode.databound dim acode string = "pps123, pps22323, pps5454, pps1231" try dim integer = 0 dim arrlist new arraylist() arrlist.addrange(acode.split(",")) = 0 arrlist.count - 1 dfallowancecode.items.add(new telerik.web.ui.radcomboboxitem(arrlist.item(i).tostring, i)) next catch ex exception response.write("an error occurred: " & e.tostring()) end try end sub
Comments
Post a Comment