Solved

How to set Dropdown List records that are not selected to be invisible or unabled?

Posted on 2008-10-15
2
240 Views
Last Modified: 2012-05-05
I have an ASP.NET page to retrieve a country name from a list of calculations. Then I forward this country name to the next page which has a dropdown list ddlCompany loaded with a list of companies. Then I need to set one record in the list to be selected (the value passed from last page I mentioned above). Now since this page is read only, I want to disable (or set to invisible) all other country records in the dropdown list so that user only sees this record in the drop down list box. Or the dropdown list is diabled so that user can see only the record which matches the value passed from last page on the dropdown list text box area. Is this possible? Thanks a lot.
0
Comment
Question by:heyday2004
2 Comments
 
LVL 5

Accepted Solution

by:
varungd earned 400 total points
ID: 22728554
Change the enable property as false for dropdownlist
eg:
<asp:DropDownList ID="DropDownList1" runat="server" Enabled="False" Width="166px">
<asp:ListItem>a</asp:ListItem>
<asp:ListItem>aa</asp:ListItem>
<asp:ListItem>b</asp:ListItem>
</asp:DropDownList>
 
c#

protected void Page_Load(object sender, EventArgs e)
{
DropDownList1.SelectedItem.Text = "B";


}
0
 
LVL 1

Assisted Solution

by:ashishkaithi
ashishkaithi earned 100 total points
ID: 22728629
Hi,
what I understood is u r sending
country value to other page and
using this name u fill the companies and
after displaying appropriate records for (COUNTRY_NAME,COMPANY_NAME) pair u want to disable it
but why if u want other pair then like.
(COUNTRY_NAME,COMP1)
(COUNTRY_NAME,COMP2)
(COUNTRY_NAME,COMP3)
If I m wrong let me knw.
If I m write and u want like u said
Go to SelectedIndexChanged event of Drodown(remember u must set autopostback=true) and
disable the dropdown
Thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now