databind dropdownlist to cache

  • Thread starter Thread starter xzzy
  • Start date Start date
X

xzzy

Problem: the following creates an empty dropdownlist

it needs to populate the dropdownlist with a list of printers

global.aspx.cs++++++++++++++++++++++++++

string l_SQL = "SELECT modRowID, modPrinterName from tblPrinters WHERE
modPrinterMfr = 1 ORDER BY modPrinterName ASC UNION Select 0 as aa, 'by
Printer' as bb from tblPrinters;";
OleDbConnection myConnection = new
OleDbConnection(Application["DDSN"].ToString());
OleDbDataAdapter myCommand1 = new OleDbDataAdapter(l_SQL,
myConnection);
System.Data.DataSet DS = new System.Data.DataSet();
myCommand1.Fill(DS);
Context.Cache.Insert("hpprinters", DS);
DS.Clear();
myCommand1.Dispose();



search.aspx(,.cs)+++++++++++++++++++++++

<td align="left" width="100"><asp:dropdownlist id="byhpprinter"
runat="server" Width="100"
OnSelectedIndexChanged="byhpprinter_SelectedIndexChanged"
AutoPostBack="True">
</asp:dropdownlist></td>

byhpprinter.DataSource=Cache.Get("hpprinters");
byhpprinter.DataTextField="modPrinterName";
byhpprinter.DataValueField="modRowID";
byhpprinter.DataBind();
 
xzzy,

Why are you calling the Clear method on DS? That's causing the list to
clear.

Hope this helps.
 
Back
Top