.net - Passing value from single C# dropdown selection to a query string -


i have dropdownlist , listbox functioning fine. need able insert selected value dropdownlist database when user moves selection products table productsmail table in listbox. have attempted modify sql string multiple times no success "+emailddn.selecteditem+" , "+emailddn.selectedvalue+", etc. can selected value display in emaillabel1 label not in query. please provide solution. appreciate time. _ jt

hi suryakiran,

in "destinationdatasource":

updatecommand="update productsmail set name = @name, email = @email, emailid = @emailid id = @id".  

i have attempted modifications such as:

"update productsmail set name = @name, email = ' + @email + ', emailid = @emailid id = @id" , "update productsmail set name = @name, email = ' +emailddn.selecteditem+ ', emailid = @emailid id = @id" 

and others no success.

<telerik:radscriptmanager id="scriptmanager" runat="server" /> <telerik:radajaxloadingpanel runat="server" id="radajaxloadingpanel1" /> <telerik:radajaxpanel runat="server" id="radajaxpanel1" loadingpanelid="radajaxloadingpanel1">   <asp:sqldatasource id="sqldatasource2" connectionstring="<%$ connectionstrings:ipdataconnectionstring %>"     providername="system.data.sqlclient" selectcommand="select distinct email [aspnet_membership]"     runat="server"></asp:sqldatasource>   <label for="emailddn">     <asp:label id="label2" runat="server" class="text">select email:&nbsp;</asp:label>   </label>   <asp:dropdownlist id="emailddn" runat="server" autopostback="true" datasourceid="sqldatasource2"     appenddatabounditems="true" datatextfield="email" datavaluefield="email" onselectedindexchanged="ddn_selectedindexchanged">     <asp:listitem>            select email address     </asp:listitem>   </asp:dropdownlist>   <br />   <br />   <asp:label id="emaillabel1" runat="server" />   <br />   <br />   <br /> </telerik:radajaxpanel> <telerik:radajaxloadingpanel runat="server" id="radajaxloadingpanel2" /> <telerik:radajaxpanel runat="server" id="radajaxpanel2" loadingpanelid="radajaxloadingpanel1">   <telerik:radlistbox runat="server" id="radlistbox1" datasourceid="sourcedatasource"     allowautomaticupdates="true" datakeyfield="id" datatextfield="name" datasortfield="sortorder"     width="230px" height="200px" allowtransfer="true" transfertoid="radlistbox2" transfermode="copy"     autopostbackontransfer="true" />   <telerik:radlistbox runat="server" id="radlistbox2" datasourceid="destinationdatasource"     allowautomaticupdates="true" datakeyfield="id" datatextfield="name" datasortfield="sortorder"     width="230px" height="200px" allowreorder="true" autopostbackonreorder="true" allowdelete="true"     autopostbackondelete="true" /> </telerik:radajaxpanel> <asp:sqldatasource id="sourcedatasource" runat="server" connectionstring="<%$ connectionstrings:ipdataconnectionstring %>"   providername="system.data.sqlclient" deletecommand="delete products id = @id"   insertcommand="insert products (name, id, email, emailid) values (@name, @id, @email, @emailid)"   selectcommand="select name, id, email products" updatecommand="update products set name = @name, email = @email, emailid = @emailid id = @id">   <updateparameters>     <asp:parameter name="name" type="string" />     <asp:parameter name="id" type="int32" />     <asp:parameter name="email" type="string" />     <asp:parameter name="emailid" type="int32" />   </updateparameters>   <deleteparameters>     <asp:parameter name="id" type="int32" />   </deleteparameters>   <insertparameters>     <asp:parameter name="name" type="string" />     <asp:parameter name="id" type="int32" />     <asp:parameter name="email" type="string" />     <asp:parameter name="emailid" type="int32" />   </insertparameters>   <selectparameters>     <asp:controlparameter controlid="emailddn" defaultvalue="select one" name="email"       propertyname="selectedvalue" />   </selectparameters> </asp:sqldatasource> <asp:sqldatasource id="destinationdatasource" runat="server" connectionstring="<%$ connectionstrings:ipdataconnectionstring %>"   providername="system.data.sqlclient" deletecommand="delete productsmail id = @id"   insertcommand="insert productsmail (name, id, email, emailid) values (@name, @id, @email, @emailid)"   selectcommand="select name, id, email productsmail" updatecommand="update productsmail set name = @name, email = @email, emailid = @emailid id = @id">   <updateparameters>     <asp:parameter name="name" type="string" />     <asp:parameter name="email" type="string" />     <asp:parameter name="emailid" type="int32" />     <asp:parameter name="id" type="int32" />   </updateparameters>   <deleteparameters>     <asp:parameter name="id" type="int32" />   </deleteparameters>   <insertparameters>     <asp:parameter name="name" type="string" />     <asp:parameter name="email" type="string" />     <asp:parameter name="emailid" type="int32" />     <asp:parameter name="id" type="int32" />   </insertparameters>   <selectparameters>     <asp:controlparameter controlid="emailddn" defaultvalue="select one" name="email"       propertyname="selectedvalue" />   </selectparameters> </asp:sqldatasource> ============================================ ============================================ protected void ddn_selectedindexchanged(system.object sender, system.eventargs e) {   emaillabel1.text = emailddn.selecteditem.tostring(); } 

in same way have used <asp:controlparameter> in <selectparameters> section can pass email value in doing in <updateparameters> section.

  <insertparameters>     <asp:parameter name="name" type="string" />     <asp:controlparameter name="email" propertyname="selectedvalue" controlid="emailddn" />     <asp:parameter name="emailid" type="int32" />     <asp:parameter name="id" type="int32" />   </insertparameters> 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -