473,395 Members | 1,977 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,395 software developers and data experts.

How to display label text when a dropdown list is selected..

Hi friends,

following is my code

Expand|Select|Wrap|Line Numbers
  1.  
  2. //================
  3.                     if (ddlColumnName.SelectedItem.Text == "call duration")
  4.                     {
  5.                         Label4.Text = "HH:MM:SS";
  6.                     }
  7.                     //=================
  8.  
  9.  
Im using c#, i have one dropdown list with n number of items. one amoung that item is call duration. If user select this option i have to display a label, say hh:mm:ss

can any one advice me the code and where exactly it should be placed.

Thanks in advance :)
Jul 23 '08 #1
9 2337
r035198x
13,262 8TB
SelectedIndexChanged event for your dropdown.
Jul 23 '08 #2
yes i have placed under SelectedIndexChanged event but still label value is not displayed..... Anything wrong in my code ?
Jul 23 '08 #3
r035198x
13,262 8TB
yes i have placed under SelectedIndexChanged event but still label value is not displayed..... Anything wrong in my code ?
Post the full code you used.
Jul 23 '08 #4
Following is the code

Expand|Select|Wrap|Line Numbers
  1.  
  2. private void ddlColumnName_SelectedIndexChanged(object sender, System.EventArgs e)
  3.         {
  4.                         if (ddlColumnName.SelectedItem.Text == "call duration")
  5.             {
  6.                 Label4.Text = "HH:MM:SS";
  7.             }
  8.                                   }
  9.  
Jul 23 '08 #5
r035198x
13,262 8TB
Following is the code

Expand|Select|Wrap|Line Numbers
  1.  
  2. private void ddlColumnName_SelectedIndexChanged(object sender, System.EventArgs e)
  3.         {
  4.                         if (ddlColumnName.SelectedItem.Text == "call duration")
  5.             {
  6.                 Label4.Text = "HH:MM:SS";
  7.             }
  8.                                   }
  9.  
Output the SelectedItem's Text just to be what it's value actually is. Perhaps they have different case or are different strings altogether.
Jul 23 '08 #6
Frinavale
9,735 Expert Mod 8TB
Following is the code

Expand|Select|Wrap|Line Numbers
  1.  
  2. private void ddlColumnName_SelectedIndexChanged(object sender, System.EventArgs e)
  3.         {
  4.                         if (ddlColumnName.SelectedItem.Text == "call duration")
  5.             {
  6.                 Label4.Text = "HH:MM:SS";
  7.             }
  8.                                   }
  9.  
Just checking: you don't actually have Label4.Visible = false; anywhere do you? If so, you should set Label4.Visible = true; in your SelectedIndexChanged event.

-Frinny
Jul 23 '08 #7
Hi friends i resolved the problem.......


Expand|Select|Wrap|Line Numbers
  1.  
  2. if (ddlColumnName.SelectedValue   == "File size")
  3.             {
  4.                                 Label4.Text = "Bytes";
  5.             }
  6.  
instead of selected value i gave selected text........that was the problem.

Thank u......
Jul 24 '08 #8
r035198x
13,262 8TB
Hi friends i resolved the problem.......


Expand|Select|Wrap|Line Numbers
  1.  
  2. if (ddlColumnName.SelectedValue   == "File size")
  3.             {
  4.                                 Label4.Text = "Bytes";
  5.             }
  6.  
instead of selected value i gave selected text........that was the problem.

Thank u......
If you had output those values as I suggested above you would have picked that up earlier.
Jul 24 '08 #9
tlhintoq
3,525 Expert 2GB
I think you will find it a good practice to take text values you are comparing and drop them both to the same case, just to be safe, since comparrisons are case-sensative.

Most of mine look like this, keeping the code readible to the coder at the cost of reducing to the smallest number of bytes...

if (MyTextBox.Text.ToLower() == "What I Expect".ToLower() )
{
// Then do something here
}

This has saved me more than once from my own typos of 'expect' rather than 'Expect' and so on.
Jul 25 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: rbinington | last post by:
Hi, I am trying to write a DNN module that has the ability to insert articles into an article repository. I want the users to be able to move pages around and enter text into the FCKEditor. I...
0
by: Kay | last post by:
Hello, I have written my own custom control and I want one of its properties to display as a dropdown list when clicked, so the user can select from the list, it would be similar to the asp...
0
by: Kay O'Keeffe | last post by:
Hello, I have written my own custom control and I want one of its properties to display as a dropdown list when clicked, so the user can select from the list, it would be similar to the asp...
2
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs,...
2
by: mervyntracy | last post by:
Hi There, I have recently started coding in asp.net (just 2 and a half days now). I am writing a simple test app that gets data from a data base and displays the value perfectly in the drop down...
3
by: WebNewbie | last post by:
Hi, please help I've been wrestling with this for a very long time and its not working. I'm trying to display text files from a database when someone selects one or more list items of my listbox. The...
0
by: neoupadhyay | last post by:
Hi Friends, Friends, I have a Dropdown List box and also i have a lable,i m using asp.net2.0 with C#, now my problem is, how can i display or change the value of selected item from dropdownlist...
18
by: Academia | last post by:
I let the use modify the text of a combobox and then I replace the selected item with the new text (in Keyup event). But if he sets the Text property to an empty string ("") that sets the...
0
by: AlDave | last post by:
What I'm trying display is after the user chooses the product (1st category) from a dropdown, then the dataview will display; The category any reports under that subcategory any...
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.