c# - How to populate a combobox with SQL Server stored procedure -
using: asp.net , c#
i'm trying populate combobox values sql server stored procedure. have combobox loading , working, don't know how make values show drop down list customer choose. listitem correct way load drop down menu?
here have far:
.aspx
page:
<asp:toolkitscriptmanager id="scriptmanager1" runat="server" /> <div> <asp:updatepanel id="updatepanel1" runat="server"> <contenttemplate> <asp:combobox id="combobox1" runat="server" datasourceid="sql" datatextfield="datatext" datavaluefield="datavalue" maxlength="0" style="display: inline;"> <asp:listitem value="0">please choose item......</asp:listitem> //what put here load , display stored procedure in list </asp:combobox> <asp:sqldatasource id="sql1" runat="server" connectionstring="<%$ companyconnectionstring %>" selectcommand="companystoredprocedure" selectcommandtype="storedprocedure"> <selectparameters> <asp:parameter name="parameterid" type="int32" /> </selectparameters> </asp:sqldatasource> <asp:label id="label1" runat="server" text=""></asp:label> </contenttemplate> </asp:updatepanel> </div> </asp:toolkitscriptmanager>
your <asp:parameter name="parameterid" type="int32" />
not filled in value, why combobox
not being populated.
you can either:
populate programmatically in code behind:
protected function page_load(object sender, eventargs e) { sql1.selectparameters["parameterid"].defaultvalue = 12; combobox1.datasource = sql1.select(datasourceselectarguments.empty); combobox1.databind(); }
or can make <asp:sessionparameter>
or <asp:controlparameter name="parameterid" type=int32" ...
that is, linking session
value or asp.net control
.
Comments
Post a Comment