Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 21st, 2008, 07:29 AM
Authorized User
 
Join Date: May 2007
Posts: 95
Thanks: 5
Thanked 0 Times in 0 Posts
Default C# code for dropdownlist

Hi all

I m making a web app. using C# and SQL Server 2005,(using duwamish architecture), just got stuck on this particular problem.

1)I have a textbox where i will enter ProjectID which is numeric in nature, after writing, i will press tab or will hit enter and it will go to first radio button named new(Note: I have two radio buttons, one new and another Modify, both are unchecked by default). When i will select 'new'; text which i have entered as for ProjectID should get checked with database that whether it is available or not, if yes then in the dropdownlist all the available project version should come( for e.g 1,2,3) but these versions should be greyed out, i should not be able to select it. Along with the existing version , a new version should come(here for 4), which i can select.

2)Same is the case with modify radio button, difference is only that in the dropdownlist all the available version should come and i can select it.

Please throw some light on this, explaining through code.How can i implement this...


 
Old January 21st, 2008, 07:40 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

You cannot have a drop down list with some disabled and some enabled items, you can only enable or disable the entire drop down list.

/- Sam Judson : Wrox Technical Editor -/
 
Old January 21st, 2008, 08:15 AM
Authorized User
 
Join Date: May 2007
Posts: 95
Thanks: 5
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by samjudson
 You cannot have a drop down list with some disabled and some enabled items, you can only enable or disable the entire drop down list.

/- Sam Judson : Wrox Technical Editor -/
I think u didnt got my point, it is about disabling the listitems in the dropdownlist, not disabling the dropdownlist.
please help me through some code...

 
Old January 21st, 2008, 08:19 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

I didn't misunderstand you, I'm telling you you can't do that. You can ONLY disable the whole drop down list.

/- Sam Judson : Wrox Technical Editor -/
 
Old January 22nd, 2008, 02:58 AM
Authorized User
 
Join Date: May 2007
Posts: 95
Thanks: 5
Thanked 0 Times in 0 Posts
Default

OK, I GOT YOUR POINT, BUT TELL HOW TO LOAD THE DROPDOWNLIST UPON SELECTING RADIO BUTTON.

 
Old January 22nd, 2008, 06:00 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

You need to make sure that AutoPostBack is set to true, and then just handle the CheckedChanged event.

/- Sam Judson : Wrox Technical Editor -/
 
Old January 23rd, 2008, 12:27 AM
Authorized User
 
Join Date: May 2007
Posts: 95
Thanks: 5
Thanked 0 Times in 0 Posts
Default

Can you just explain me through code. The case is: on selecting radio button(named 'new')
it should check the text supplied in the textbox from the database, on returning true, it should load values from the database to the dropdownlist.

Please help through code, i m struggling hard to get it right.

 
Old January 23rd, 2008, 05:14 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Firstly, 'new' is a very bad name for anything in C# as it is a reserved keyword. Called it NewRadioButton.

Which bit are you having trouble with? Have you added the event to the radio button? Do you know how to do that? Are you using visual studio? Have you changed the AutoPostBack property? Do you know how to do that? Do you know how to connect to a database? The questions go on....

If you have some code you've written which doesn't work then post it and we'll try to help, either that or be more specific in your problem.

/- Sam Judson : Wrox Technical Editor -/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 8 - Code doesn't produce a DropDownList cscooper2000 BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 0 November 3rd, 2007 06:16 PM
DropDownList Lu5ck ASP.NET 2.0 Basics 3 October 13th, 2006 04:05 AM
dropdownlist code-value pair mapping gagansharma7 General .NET 0 June 27th, 2006 02:11 PM
how to get value from dropdownlist vandat ASP.NET 1.0 and 1.1 Basics 3 November 28th, 2005 12:47 AM
DropDownList.. cybercross VB How-To 2 October 19th, 2004 07:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.