473,382 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

databind dropdownlist to cache

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_SelectedIndexC hanged"
AutoPostBack="True">
</asp:dropdownlist></td>

byhpprinter.DataSource=Cache.Get("hpprinters");
byhpprinter.DataTextField="modPrinterName";
byhpprinter.DataValueField="modRowID";
byhpprinter.DataBind();
Nov 16 '05 #1
2 2357
xzzy,

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

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"xzzy" <mr********@comcast.net> wrote in message
news:nv8fd.421216$mD.31868@attbi_s02...
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_SelectedIndexC hanged"
AutoPostBack="True">
</asp:dropdownlist></td>

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

Nov 16 '05 #2
Thank you for your help.
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Srinivas | last post by:
Hi, My function returns a datareader object containing only one column of datatype money. In asp.net I want to bind this datareader to a dropdownlist. Can anyone suggest me how to do this with...
18
by: Julia Hu | last post by:
Hi, I have a datagrid, and in different rows I need to programmatically bind different type of controls and load data into these controls. For example,in the first row I need to bind data into a...
0
by: Bryce Budd | last post by:
Hi, I have a webform which has several server controls attached. The entire form is data bound to custom objects. The collection objects are cached using the Cache object. In my use case, I...
2
by: Jim Bancroft | last post by:
Hi everyone, I have a DropDownList I populate as outlined below. This is from my code-behind file: private void Page_Load(object sender, System.EventArgs e) { BindMyData(); DataBind(); }
2
by: Olav Tollefsen | last post by:
I have a Web Form with a DataList. Inside the ItemTemplate, I have a DropDownList control. <asp:DataList ID="ProductDataList" Runat="server"> <ItemTemplate> <asp:DropDownList ID="DropDownList1"...
2
by: Jimmy | last post by:
Hi all I want to databind a dropdownlist in a datagrid: private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here
1
by: John Blair | last post by:
Hi, how do i reset a dropdownlist selectedindex value to a specific value - when the dropdownlist isa in a custom grid header, is data bound, and the main grid has been rebound to its...
0
by: murfu | last post by:
I have a formview that has a dropdownlist bound to a table to populate a list of people. While in edit mode, if a person is not in that list, there is a button that pops up an add requester page...
6
by: Jonathan Wood | last post by:
I have a databound dropdownlist control. Based on some other criteria, I need to specify the selected item in my pages Load event. The problem is that, in my load event, the control does not yet...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.