asp.net - Error when Binding Data to SQLDataSource inside an Update Panel -
i trying use update panel within insertitemtemplate of formview. when "other" selected 1 dropdownlist, dropdownlist hidden. when remove update panel works fine, record created no problem. when dropdownlist inside updatepanel, following error on inserting :
oracle.dataaccess.client.oracleexception: ora-01008: not variables bound.
i haven't included of asp.net , code behind, please ask if you'd see else, there more bound fields , alot of data validation. here part of asp.net:
<asp:formview id="fvjobs" datasourceid="fvsqldatasource" datakeynames="job_id" defaultmode="edit" oniteminserting="fvjobs_fileupl" oniteminserted="fvjobs_iteminserted" onitemupdating="fvjobs_fileup2" onitemupdated="fvjobs_itemupdated" runat="server"> <asp:dropdownlist id="insertloclist" selectedvalue='<%# bind("job_location") %>' autopostback="true" cssclass="ddl" onselectedindexchanged="insertloclist_indexchanged" runat="server" > <asp:listitem text="--select one--" value="-1" /> <asp:listitem text="california" value="ca" /> <asp:listitem text="new york" value="ny" /> <asp:listitem text="pennsylvania" value="pa" /> <asp:listitem text="texas" value="tx" /> <asp:listitem text="other" value="o" /> </asp:dropdownlist></label> <asp:updatepanel id="updatepanel1" updatemode="conditional" runat="server"> <triggers> <asp:asyncpostbacktrigger controlid="insertloclist" /> </triggers> <contenttemplate> <span><asp:label id="insertcatlbl" runat="server"><b>subsidiary:</b></asp:label></span> <asp:dropdownlist id="insertcatlist" selectedvalue='<%# bind("job_category") %>' cssclass="ddl" runat="server" > <asp:listitem text="--select one--" value="-1" /> <asp:listitem text="src" value="src" /> <asp:listitem text="frn" value="frn" /> <asp:listitem text="supdist" value="supdist" /> <asp:listitem text="stream" value="stream" /> </asp:dropdownlist> </contenttemplate> </asp:updatepanel> here of code behind:
protected sub insertloclist_indexchanged(sender object, e eventargs) dim ddlloc dropdownlist = _ ctype(fvjobs.findcontrol("insertloclist"), dropdownlist) dim ddlcat dropdownlist = _ ctype(fvjobs.findcontrol("insertcatlist"), dropdownlist) dim catlbl label = _ ctype(fvjobs.findcontrol("insertcatlbl"), label) if ddlloc.selectedvalue = "o" ddlcat.selectedvalue="src" ddlcat.visible=false catlbl.visible=false else ddlcat.visible = true catlbl.visible = true end if end sub the strange thing works if remove updatepanel. can't figure out why bind inside update panel doesn't seem working. i've phrased google searches every way can think of , can't seem find similar problem, appreciated, thanks.
update here sqldatasource formview:
<asp:sqldatasource id="fvsqldatasource" connectionstring="<%$ connectionstrings:oracle %>" providername="<%$ connectionstrings:oracle.providername %>" selectcommand="select job_desc, job_id, job_category, job_location, job_date_begin, job_date_closed, job_filename, job_show_indic job_posting job_id = :job_id" runat="server" updatecommand="update job_posting set job_desc=:job_desc, job_location=:job_location, job_category=:job_category, job_date_begin=to_date(:job_date_begin, 'mm/dd/yyyy'), job_date_closed=to_date(:job_date_closed, 'mm/dd/yyyy'), job_filename=:job_filename,job_show_indic=:job_show_indic job_id=:job_id" insertcommand="insert job_posting(job_desc, job_id, job_location, job_category, job_date_begin, job_date_closed, job_filename, job_show_indic) values (:job_desc, :job_id, :job_location, :job_category, to_date(:job_date_begin, 'mm/dd/yyyy'), to_date(:job_date_closed, 'mm/dd/yyyy'), :job_filename, :job_show_indic)" > <selectparameters> <asp:parameter name="job_id" type="string" defaultvalue="0" /> </selectparameters> <updateparameters> <asp:parameter name="job_id" type="string" defaultvalue="0"/> </updateparameters> </asp:sqldatasource>
i got working. after more digging discovered known bug when nesting updatepanel within formview's edititemtemplate or insertitemtemplate. there 2 ways work around this, used controlparameter bind dropdownlist in sqldatasource:
<insertparameters> <asp:parameter name="job_desc" /> <asp:parameter name="job_id" /> <asp:parameter name="job_filename" /> <asp:parameter name="job_show_indic" /> <asp:parameter name="job_location" /> <asp:controlparameter controlid="fvjobs$insertcatlist" name="job_category" /> <asp:parameter name="job_date_begin" /> <asp:parameter name="job_date_closed" /> </insertparameters> use controlparameters controls inside updatepanel.
another work around bind data on inserting/updating in code behind:
protected sub rolesqldatasource_updating(byval sender object, byval e system.web.ui.webcontrols.sqldatasourcecommandeventargs) handles rolesqldatasource.updating e.command.parameters("@street_name").value = street_nametextbox.text e.command.parameters("@street_type").value = street_typetextbox.text e.command.parameters("@street_dir").value = street_dirtextbox.text e.command.parameters("@street_number").value = street_numbertextbox.text e.command.parameters("@street_apt").value = street_apttextbox.text e.command.parameters("@city").value = citytextbox.text e.command.parameters("@state").value = statetextbox.text e.command.parameters("@zip").value = ziptextbox.text e.command.parameters("@district_id").value = districtdropdownlist.selectedvalue end sub. here links resources used:
Comments
Post a Comment