473,651 Members | 3,007 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dropdownlist question

I have a C# asp.net webform that contains a dropdownlist and a button that
allows the user to select another item in the dropdownlist. The webform
should work as follows:

When the user selects an item in the dropdownlist and clicks the button, his
selection will appear as a line of text somewhere in the webform. The user
can then select another item and clicks the button and his selection will
again appear as a line of text.

In order to avoid duplication, I need to remove (or disable) the selected
item from the dropdownlist. That way, the user wont be able to select an item
that he previously selected. I need to do this without modifying the
database. My code follows and thanks in advance.

string sCCI = "SELECT activity_no,des 1
category,Conver t(activity_uom, 'US7ASCII') bill_rate "
+ "FROM pa_activity "
+ "WHERE (activity_no LIKE Upper('D0%') or activity_no LIKE Upper('S0%'))
And last_status <> 'D' "
+ " And activity_type = 'L' "
+ "ORDER BY des1 ";
OracleConnectio n oraConn = new OracleConnectio n(connStr);
OracleCommand oraCMD = new OracleCommand(s CCI, oraConn);
oraConn.Open();
OracleDataAdapt er adapter = new OracleDataAdapt er(oraCMD);
DataSet ds = new DataSet();
adapter.Fill(ds );
if (ds.Tables[0].Rows.Count > 0)
{
ddlConsultantCa tegory.DataSour ce = ds.Tables[0];
ddlConsultantCa tegory.DataText Field = "category";
ddlConsultantCa tegory.DataValu eField = "category";
ddlConsultantCa tegory.DataBind ();
ddlConsultantCa tegory.Items.In sert(0, "(Select Consultant Category)");
}
oraConn.Close() ;

where ddlConsultantCa tegory is the dropdownlist.

Nov 17 '05 #1
2 2373
Hi,
Use DropDownList.It ems.Remove ( DropDownList1.S electedItem ) or
DropDownList.It ems.RemoveAt ( DropDownList1.S electedIndex )
BTW, the code you posted is only the DB access portion, do you have problem
with it?
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Newbie" <Ne****@discuss ions.microsoft. com> wrote in message
news:EE******** *************** ***********@mic rosoft.com...
I have a C# asp.net webform that contains a dropdownlist and a button that
allows the user to select another item in the dropdownlist. The webform
should work as follows:

When the user selects an item in the dropdownlist and clicks the button,
his
selection will appear as a line of text somewhere in the webform. The
user
can then select another item and clicks the button and his selection will
again appear as a line of text.

In order to avoid duplication, I need to remove (or disable) the selected
item from the dropdownlist. That way, the user wont be able to select an
item
that he previously selected. I need to do this without modifying the
database. My code follows and thanks in advance.

string sCCI = "SELECT activity_no,des 1
category,Conver t(activity_uom, 'US7ASCII') bill_rate "
+ "FROM pa_activity "
+ "WHERE (activity_no LIKE Upper('D0%') or activity_no LIKE Upper('S0%'))
And last_status <> 'D' "
+ " And activity_type = 'L' "
+ "ORDER BY des1 ";
OracleConnectio n oraConn = new OracleConnectio n(connStr);
OracleCommand oraCMD = new OracleCommand(s CCI, oraConn);
oraConn.Open();
OracleDataAdapt er adapter = new OracleDataAdapt er(oraCMD);
DataSet ds = new DataSet();
adapter.Fill(ds );
if (ds.Tables[0].Rows.Count > 0)
{
ddlConsultantCa tegory.DataSour ce = ds.Tables[0];
ddlConsultantCa tegory.DataText Field = "category";
ddlConsultantCa tegory.DataValu eField = "category";
ddlConsultantCa tegory.DataBind ();
ddlConsultantCa tegory.Items.In sert(0, "(Select Consultant Category)");
}
oraConn.Close() ;

where ddlConsultantCa tegory is the dropdownlist.

Nov 17 '05 #2
Thanks a lot, sir. It's working! I do have another question which I'll post
later.

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,
Use DropDownList.It ems.Remove ( DropDownList1.S electedItem ) or
DropDownList.It ems.RemoveAt ( DropDownList1.S electedIndex )
BTW, the code you posted is only the DB access portion, do you have problem
with it?
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Newbie" <Ne****@discuss ions.microsoft. com> wrote in message
news:EE******** *************** ***********@mic rosoft.com...
I have a C# asp.net webform that contains a dropdownlist and a button that
allows the user to select another item in the dropdownlist. The webform
should work as follows:

When the user selects an item in the dropdownlist and clicks the button,
his
selection will appear as a line of text somewhere in the webform. The
user
can then select another item and clicks the button and his selection will
again appear as a line of text.

In order to avoid duplication, I need to remove (or disable) the selected
item from the dropdownlist. That way, the user wont be able to select an
item
that he previously selected. I need to do this without modifying the
database. My code follows and thanks in advance.

string sCCI = "SELECT activity_no,des 1
category,Conver t(activity_uom, 'US7ASCII') bill_rate "
+ "FROM pa_activity "
+ "WHERE (activity_no LIKE Upper('D0%') or activity_no LIKE Upper('S0%'))
And last_status <> 'D' "
+ " And activity_type = 'L' "
+ "ORDER BY des1 ";
OracleConnectio n oraConn = new OracleConnectio n(connStr);
OracleCommand oraCMD = new OracleCommand(s CCI, oraConn);
oraConn.Open();
OracleDataAdapt er adapter = new OracleDataAdapt er(oraCMD);
DataSet ds = new DataSet();
adapter.Fill(ds );
if (ds.Tables[0].Rows.Count > 0)
{
ddlConsultantCa tegory.DataSour ce = ds.Tables[0];
ddlConsultantCa tegory.DataText Field = "category";
ddlConsultantCa tegory.DataValu eField = "category";
ddlConsultantCa tegory.DataBind ();
ddlConsultantCa tegory.Items.In sert(0, "(Select Consultant Category)");
}
oraConn.Close() ;

where ddlConsultantCa tegory is the dropdownlist.


Nov 17 '05 #3

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

Similar topics

2
17002
by: Dominic | last post by:
Hi guys, I'm not sure if this question belongs to FAQ, but I couldn't find a concrete answer. I created a Datagrid control using ItemTemplate, but it's NOT a in-place editing datagrid. One of the columns of the data grid contains a DropDownlist. I managed to create this datagrid control as follows.
1
1308
by: | last post by:
This is a crosspost from a less-frequented (but more focused) asp.net group; I didn't receive an answer that worked. I'd like to get this form functional. Could someone help on what's probably a simple syntax issue? I've attempted my due diligence with the usual books and references...but I'm new to ASP.NET. Question follows: The Code Project has a nice article on making a "self configuring form mailer web control." Basically, you apply...
3
4369
by: Tim::.. | last post by:
Can someone please tell me how I go about preselecting an item in a drop drown list when I click the Edit Command in a datagrid? I have tried the following but it doesn't work for me! I would be really grateful for any assistance! Thanks
6
5527
by: Julius Fenata | last post by:
Dear all, I have created client-side scripting to trigger event onChange from code-behind, like this: DropDownList1.Attributes = "GenerateArticleID()"; At the script on Windows Form, I added this function to have the value of DropDownList1
1
2176
by: Phil | last post by:
I would like to make the CreateUserWizard's security question box display as a databound (xml file) dropdownlist. I can make the dropdownlist display by using a contenettemplate, but I can't get the databinding to work. When I reference the control I receive an error saying it doens't exist. I assume the control is buried within the CreateUserWizard, but I can't seem to find it. Thanks, Phil
0
1269
by: Juanjo | last post by:
Hi, Before, I was working with Asp.net 1.0 and datagrid. I posted a question for this issue. The solution of this problem is load the second dropdownlist on the selectedindexchanged event of the first dropdownlist. Now, I'm working with ASP.net 2.0 and the gridview. I apply the same method but the second dropdownlist don't shows the rows filtered, it shows the rows filtered when the gridview was loaded for the first time.
4
1729
by: glenn | last post by:
Hi folks, I am getting an error "Object reference not set to an instance of an object". It seems I have everything in place but something is obviously in err. If you could take a quick peak at my code segments and provide any insight in a reply, I would be eternally grateful. My table name is "rfi" and the field with a dropdownlist control is called "contract". I have imported the System.Data and System.Data.OleDb libraries. ...
1
2028
by: DJ | last post by:
I have a DropDownList in Visual Web Developer that is databound to a SQL Database. Whenever the web page is opened the DropDownList is automatically filled with the first item in the table. My question is, how do I set it so that the DropDownList is empty until a value is selected?
6
4269
by: shashi shekhar singh | last post by:
Respected Sir, I have to create multiple dynamic dropdownlist boxes and add items dynamically in <asp:table> server control but problem occurs , i.e. except of fist dropdown list no dropdownlist boxes are generating a postback.here is a code . protected void Page_Load(object sender, EventArgs e) { int selected_question = (int)Session; if (!Page.IsPostBack) { display_blueprint(); string...
0
8807
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8701
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8466
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7299
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5615
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4290
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2701
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.