Where parameters in EntitydataSource from dropdown control -
using following markup, details view not populating when dropdown selected. id parameter come dropdwon selected value.it appears control parameter not functioning properly.
<asp:updatepanel id="updteditcontact" runat="server"> <contenttemplate> <asp:dropdownlist id="ddlcontacttoedit" runat="server" cssclass="dropdowns" autopostback="true" clientidmode="static"/> <asp:detailsview id="dveditcontacts" runat="server" height="50px" width="125px" autogenerateeditbutton="true" cssclass="mgrid"/> <asp:entitydatasource id="edsselectedcontact" runat="server" connectionstring="name=webentities" defaultcontainername="webentities" enableflattening="false" entitysetname="contacts"> <whereparameters> <asp:controlparameter controlid="ddlcontacttoedit" name="id" propertyname="selectedvalue" type="int32" /> </whereparameters> </asp:entitydatasource> </contenttemplate> <triggers> <asp:asyncpostbacktrigger controlid="rbladdeditcontact" eventname="selectedindexchanged"/> <asp:asyncpostbacktrigger controlid="ddlcontacttoedit" eventname="selectedindexchanged"/> </triggers> </asp:updatepanel>
upon further research, tedious there isn't lot of actual entitydatasource control since of our ef work in code behind, there 3 issues
- i did not have attribute in eds markup
- the "type" in whereparameter needs dbtype
- the name attribute of whereparameter match variable in statement in eds markup
here code works:
<asp:updatepanel id="updteditcontact" runat="server"> <contenttemplate> <asp:dropdownlist id="ddlcontacttoedit" runat="server" cssclass="dropdowns" autopostback="true" clientidmode="static"/> </contenttemplate> <triggers> <asp:asyncpostbacktrigger controlid="rbladdeditcontact" eventname="selectedindexchanged"/> </triggers> </asp:updatepanel> <br /> <asp:updatepanel id="updateditcontactdetail" runat="server"> <contenttemplate> <asp:detailsview id="dveditcontacts" runat="server" height="50px" width="300px" datasourceid="edsselectedcontact" datakeynames="id" visible="false" cssclass="mdetail" fieldheaderstyle-cssclass="fieldheader" itemstyle-cssclass="itemvalues" commandrowstyle-cssclass="cmdrow" editrowstyle-cssclass="editvalues" clientidmode="static" insertrowstyle-cssclass="insertvalues" rowstyle-cssclass="rowvalues"/> <asp:entitydatasource id="edsselectedcontact" runat="server" connectionstring="name=webentities" defaultcontainername="webentities" enableflattening="false" entitysetname="contacts" where="it.id = @id"> <whereparameters> <asp:controlparameter controlid="ddlcontacttoedit" name="id" propertyname="selectedvalue" dbtype="int32"/> </whereparameters> </asp:entitydatasource> </contenttemplate> <triggers> <asp:asyncpostbacktrigger controlid="ddlcontacttoedit" eventname="selectedindexchanged"/> </triggers> </asp:updatepanel>
Comments
Post a Comment