hide only the dropdown value while selecting the another dropdown value

 hai  friend i am using two dropdown list

if i select one dropdownlist

the another dropdownlist value must be hide

what can i do for this

 
















 

 



Ramesh.D
http://rameshduraikannu.blogspot.com
0
rameshduraikannu
1/18/2008 5:07:15 AM
asp.net.web-forms 93655 articles. 5 followers. Follow

7 Replies
673 Views

Similar Articles

[PageSpeed] 53

 u can do that using javascript..

function Hide()

{

 var drop1 = document.getElementById('<%=dropdownlist1.ClientID%>')

 var drop2 = document.getElementById('<%=dropdownlist2.ClientID%>') 

if(drop1.selectedIndex >0) 

{

drop2 .style.display="none"

}

else

{

drop1 .style.display="none"

if(drop2.selectedIndex >0) 

{

drop1 .style.display="none"

}

else

{

drop2 .style.display="none"

}

 

call this javascript on selectedIndexchanged of both the dropdown 


Babs
0
prince_prince_23
1/18/2008 5:38:43 AM

Hi

what exactly u want : hiding the whole second dropdownlist or only the value in the dropdownlist...

reply...so that i can try to solve it

Nick


Regards Nick,

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

If this solution doesn't solve your problem, just feel free to mark it as not answer and reply.
0
nickgenius
1/18/2008 6:04:02 AM

 only the second dropdownlist  value


Ramesh.D
http://rameshduraikannu.blogspot.com
0
rameshduraikannu
1/18/2008 6:48:44 AM

 only the second dropdownlist value must be hide when i am select the first dropdown list

Ramesh.D
http://rameshduraikannu.blogspot.com
0
rameshduraikannu
1/18/2008 6:51:14 AM

That means u want an empty dropdownlist. Ok now tell me that whether ur second dropdownlist is filled through hardcode or thru database....

and please provide me the code...so that i can clearly go thru it.....

And try the code written below on DropDownList1_SelectedIndexChanged event (if u hardcode the the items in dropdownlist):

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)

{

DropDownList2.Items.Clear();

}

//this will remove all items stored in dropdownlist2...

cheers

Nick

Please click on "mark as answer" if my replies help u to get out of ur problem..

 


Regards Nick,

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

If this solution doesn't solve your problem, just feel free to mark it as not answer and reply.
0
nickgenius
1/18/2008 10:07:56 AM

html view

 

<table class="contacts" cellspacing="0"  id="tbl1" runat="server"  >
                        <tr>
                            <td  colspan="3" style="height: 20px; background-color:#869bb3;" align="center">
                                Project Search</td>
                        </tr>
                        <tr>
                            <td class="label1" style="background-color:#ced6dd; width: 25%" align="left">
                                <asp:Label ID="lblProject_Name" runat="server" Text="Project Name"></asp:Label>
                            </td>
                            <td style="background-color:#ced6dd;">
                               <asp:DropDownList ID="drpProject_Name" CssClass="list" runat="server" Width="336px" >
                                   
                                </asp:DropDownList></td>
                        </tr>
                        <tr>
                            <td align="left" class="label1" style="background-color:#ced6dd; width: 25%">
                            </td>
                            <td style="background-color:#ced6dd;">
                            </td>
                        </tr>
                        <tr>
                            <td class="label1" style="background-color:#ced6dd; width: 25%" align="left">
                                 <asp:Label ID="lblClient_Name" runat="server" Text="Client Name"></asp:Label>
                            </td>
                            <td style="background-color:#ced6dd;">
                                <asp:DropDownList ID="drpClient_Name" CssClass="list" runat="server" Width="336px">
                                  
                                </asp:DropDownList></td>
                        </tr>
                        <tr>
                            <td align="left" class="label1" style="background-color:#ced6dd; width: 25%; height: 21px;">
                            </td>
                            <td style="background-color:#ced6dd; height: 21px;">
                            </td>
                        </tr>
                           
                    </table>

 

 

when the page is load. 

page_load()

if (!IsPostBack)
        {
            Project_Name();
            client_Name();
        }

 }

 

#region To fill the project
    /// <summary>
    /// Dropdown project_Name
    /// </summary>
    public void Project_Name()
    {
        Dal=new DataAccesslayer();
        DataSet ds = Dal.RetrieveDataSet_Text("select distinct proj_code,proj_name from project_master where proj_status='A' and delflag='F' order by proj_name");
            foreach (DataRow dr in ds.Tables[0].Rows )
            {
                drpProject_Name.Items.Add(dr["proj_name"].ToString());
            }
    }
    #endregion

 

#region Dropdown Client_Name
    public void client_Name()
    {
       DataSet ds=Dal.RetrieveDataSet_Text("select distinct(client_master.client_name),project_master.client_code from client_master,project_master where project_master.client_code=client_master.client_code and proj_status='A' and project_master.delflag='F' order by client_master.client_name ");
       foreach (DataRow  dr in ds.Tables[0].Rows)
       {
           drpClient_Name.Items.Add(dr["client_name"].ToString() );
       }
    }

    #endregion

 

the above code is for two dropdownlist value  when the page is load

in that if i select the first dropdownlist the second dropdownlist value must be hide

likewise if i select the frist dropdownlist the second dropdownlist value must be hide.

i think this will understand clearly 

 


 


Ramesh.D
http://rameshduraikannu.blogspot.com
0
rameshduraikannu
1/18/2008 10:53:40 AM

Hi rameshduraikannu,

I have write a completely sample to demonstrate how you can fulfill the function above, please check the demo
below.

<!--File: Default5.aspx-->
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs" Inherits="Default5" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <table class="contacts" cellspacing="0"  id="tbl1" runat="server"  >
                        <tr>
                            <td  colspan="3" style="height: 20px; background-color:#869bb3;" align="center">
                                Project Search</td>
                        </tr>
                        <tr>
                            <td class="label1" style="background-color:#ced6dd; width: 25%" align="left">
                                <asp:Label ID="lblProject_Name" runat="server" Text="Project Name"></asp:Label>
                            </td>
                            <td style="background-color:#ced6dd;">
                               <asp:DropDownList ID="drpProject_Name" CssClass="list" runat="server" Width="336px"  AutoPostBack="true" OnSelectedIndexChanged="OnProject_sel_changed">
                                   
                                </asp:DropDownList></td>
                        </tr>
                        <tr>
                            <td align="left" class="label1" style="background-color:#ced6dd; width: 25%">
                            </td>
                            <td style="background-color:#ced6dd;">
                            </td>
                        </tr>
                        <tr>
                            <td class="label1" style="background-color:#ced6dd; width: 25%" align="left">
                                 <asp:Label ID="lblClient_Name" runat="server" Text="Client Name"></asp:Label>
                            </td>
                            <td style="background-color:#ced6dd;">
                                <asp:DropDownList ID="drpClient_Name" CssClass="list" runat="server" Width="336px" AutoPostBack="true" OnSelectedIndexChanged="OnClient_sel_changed">
                                  
                                </asp:DropDownList></td>
                        </tr>
                        <tr>
                            <td align="left" class="label1" style="background-color:#ced6dd; width: 25%; height: 21px;">
                            </td>
                            <td style="background-color:#ced6dd; height: 21px;">
                            </td>
                        </tr>
                           
                    </table>

    </div>
    </form>
</body>
</html>

//File: Default5.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Default5 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Project_Name();
            client_Name();
        }
    }

        #region To fill the project
    /// <summary>
    /// Dropdown project_Name
    /// </summary>
    public void Project_Name()
    {
        drpProject_Name.Items.Clear();
        drpProject_Name.Items.Add(new ListItem("Proj_item1","Proj_item1"));
        drpProject_Name.Items.Add(new ListItem("Proj_item2", "Proj_item2"));
        drpProject_Name.Items.Add(new ListItem("Proj_item3", "Proj_item3"));
           
    }
    #endregion

 

#region Dropdown Client_Name
    public void client_Name()
    {
        drpClient_Name.Items.Clear();
        drpClient_Name.Items.Add(new ListItem("Client_item1", "Client_item1"));
        drpClient_Name.Items.Add(new ListItem("Client_item2", "Client_item2"));
        drpClient_Name.Items.Add(new ListItem("Client_item3", "Client_item3"));
     
    }

    #endregion

    protected void OnProject_sel_changed(object sender, EventArgs e)
    {
        drpClient_Name.Items.Clear();
    }


    protected void OnClient_sel_changed(object sender, EventArgs e)
    {
        drpProject_Name.Items.Clear();
    }
  
}

Regards,
Xun


Regards,
Xun Ye.
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that
helps you, and to click “Unmark as Answer” if a marked post
does not actually answer your question. This can be beneficial
to other community members reading the thread.
0
Xun
1/22/2008 6:00:10 AM
Reply:

Similar Artilces:

dropdown selected value and dropdown no value saved
 is there any way the selected value is selected already when i try to edit the gridview ... and another thing... when i edit this dropdown.. no value was being saved... what is wrong or missing.. please help... i almost spend two days on this problem...i've read many post about this.. but still i didn;t get it... please help///  <asp:TemplateField HeaderText="Unit" SortExpression="UnitID">                          &...

can i drag the selected value of dropdown list in one web part to another web part
hi, supose i am having time displaying in on webpart can i drag the value of time to another web part and and display the time is: and the value draged from the other webpart so i want to drag the value year and population into antoher web part and according to that the grap must appear i.e what  i exactly want is i must drag some value from one webpart to onother webpart and according to event some thing must happen in another web part   Hi, The problem has been replied in the following post: http://forums.asp.net/t/1141884.aspx But from the title you described, do ...

Populate dropdown list based on selected value in another dropdown list
I have a datagrid (grdCar) that contains two dropdown listboxes (ddlCarManf and ddlCar). When the user clicks the "Edit" link and places the grid into edit mode, they select a value in ddlCarManf. Based on the selected value in ddlCarManf, I need to then populate ddlCar with a list of cars for which the selected manufacturer makes (I'm using ddlCarManf.SelectedValue to query the database).  I bind my datagrid in the page_load event as: If Not Page.IsPostBack Then    BindGrid() End If Here is my control (ddlCarManf) as is appears within grdCar in ...

On selecting of radio button, set the value of one dropdown box = to another dropdown box
I have a simple vb.net form.  On it is a drop down box, a radio button list, and another drop down box.     First the user makes a selection in the drop down box, then if they select "yes" in the radio button list, I need the change the value of the 2nd drop down box to equal the value from the first drop down box.  I've tried the following, but it doesn't work.. thr...  any suggestions? my codebehind.. where Iam trying to set the selectedvalue of BillingAttorneyID = AttorneyIDProtected Sub rbBillingSplitYes_CheckedChanged(ByVal sender As...

Cascading Dropdown - Initially selected value
Hi there, I am having an issue with a pretty basic problem. I have managed to get the cascading drop down lists working ok with information coming from a database. On the initial page, I need to have a value in the drop down list already selected, i.e. the current year in one drop down and current month in the next. The information from both of these is sent to a query to output a datatable. Can anyone help with this? I'm not sure I understand the scenario, but I think the new CascadingDropDownNameValue(..., defaultValue) constructor may be just what you're looking for. (First available ...

Get selected dropdown value to appear in another textbox on same form
Hi all,As is stated in the title, I need to get a selected dropdown value to appear in another textbox on the same vb.net form.Now I presume I am going to have to use javascript to achieve this? Problem is I have zip javascript experience. Would someone be able to point me in the direction of an online example not too dissimilar to what I need above?Would appreciate it a lot, thanks.  My VB.NET is a little rusty but it should be something like this in the code behind:  YourSelectControl.Attributes.Add("onchange", "document.getElementById('" + YourTex...

Filtering dropdown with values from another dropdown
I have a populated datagrid. When I edit this grid, I am displaying a Category/SubCategory column. Inside this column, I have a dropdownlist for the Category. Upon selection of a category, I need to poplulate the SubCategory dropdownlist with the selected categories appropriate subcategories. I have everything setup for autopostback, so I'm not concerned about writing clientside script. The return trip to the app server is of no consequence in this situation. The basic problem is now that I can't get the appropriate values into the SubCategory box. I don't know how to access that indiv...

cascading dropdown set it's value only once but not on subsequent postbacks,web service recieve the value but can't set in dropdown
i have a dropdown named uxcommunity which is a dropdown and contain text in format ##-####-#### . and 2 more dropdowns province and district where province filters district. i get the first 2 characters ##  for session("province") and #### for session("District") and i have button to do the postback. first when the form loads and i click the button it get the value and select appropraite items in to dropdown province and district. but when i change the province dropdown content and district dropdown content and click the button , session will take correct...

Cascading Dropdown List
Hi, First post so hello and need some help with an issue I have been dealing with.  I have an intranet page I created in ASP.NET using C# .NET 3.5 with a few Ajax Extenders including 3 Cascading Dropdown Lists. Now I have used the Cascading dropdown lists for my own purposes i.e they do not actually cascade their results to another dropdown list, the reason I did this was due to the having a User Control that contains an update panel and other bits i.e I didn't want the control/page posting page (something that happens when you click on a regular dropdown list). Everything is wor...

Cascading Dropdown Selected values and Default values
I am loading the cascading dropdown control with data from my database implementing web service methods written in VB, and cascading dropdown control runs fine. Now as in any classic application I would like giving default values to  3 dropdown lists concerned with cascading and also getting back selected entries to call my database to retrieve records with values read as criteria. First I tried to postback with a button control after selecting entries in cascading dropdown control, but the resulting selected values are empty. Can anyone help. Hi, As you click the Button...

adding values to the selected value in Dropdown list
 Hi,   I have dropdown box in my page which have some value inherted from the another list box in my page..Now in my second page , i have dropdown box with values and text value and list box... I'll be selecting the one value from the dropdown then i enter the value in text box and click on add button which will add the value in the list box like this i can able to add many value...now if i click on save button for the selected dropdpown item the added values in the listbox should be saved ...like this i add many values for many dropdown item and saved respectivelynow if c...

problem in selecting value from dropdown inside a repeater and inserting the selected value inside db
there is  checkbox and drop down inside my  item template of repeater in one page.Based on that drop down and check box selection calculation will be done in another page which will be inserted inside a db.I cannnot fetch the value from the dropp down in my save page  and as a resut data cannot be inserted inside db. plz help!!  <asp:Repeater ID="rptmenproduct" runat="server" >                      <HeaderTemplate>    <...

Dropdown woes. Need to db value to correspond with dropdown value
I have a dropdown that I need to have set to the selected index of a value thats returned from the DB, an integer that represents the userID. I have the value returned fine but I' struggling to convert it into the number it needs to be to correspond with the dropdown index. I can do it with text items with the following: - Action_DD.SelectedIndex = Action_DD.Items.IndexOf( Action_DD.Items.FindByText(insertJobRow[JobData.NEXT_ACTION_FIELD].ToString())); but i need to do the above for integer values. Any one know how. Have you tried using the FindByValue() method in place of ...

How to use values from two dropdown lists to get the value for a third dropdown?
I have three dropdown lists.  One for Office, one for Department, and a list of employees.   There is no relationship in the database between office and department.  The relationships are to the employees.  What I need to do is take the selected values from Office and Department, and run a query to get the list of employees who match both parameters (Office & Department).  Here's my code for the three dropdown lists.  How do I "connect" Office & Department to populate employees?  code from my vb.net page    for the ...

Web resources about - hide only the dropdown value while selecting the another dropdown value - asp.net.web-forms

Consultation Document on the Methods for Selecting the Chief Executive and for Forming the LegCo in 2012 ...
The " Consultation Document on the Methods for Selecting the Chief Executive and for Forming the LegCo in 2012 " was a document published on ...

Voting Machine Caught on Camera Casting Ballot for Democrat when Selecting Republican - YouTube
**UPDATE.... I've heard many reports that this is "just a calibration issue." I will say this... when I went to page 2 and began voting for city ...

Selecting decor that will move with the times
What colours should I use in my home so that my d&#233;cor is neutral and flexible but not boring?

Clock ticking on selecting successor to Leigh Clifford at Qantas
With Qantas on course to chalk up its largest annual profit since 2008, the question now is whether chairman Leigh Clifford is looking to hang ...

More to selecting political background music than indiscriminate meandering
Gathering a song to use as a protest weapon can backfire.

Jackie French: Why selecting the right place for your plants is important
The secret of growing anything easily is to choose the best spot for what you want to grow.

Liberals begin 'super weekend' of selecting delegates
A race for the top job in the federal Liberal party gained momentum on Friday as rank and file party members began the selection process for ...

Boston Marathon bombing trial: Judge, lawyers face challenges in selecting jurors - CTV News
As the second phase of jury selection began in the federal death penalty trial of Boston Marathon bombing suspect Dzhokhar Tsarnaev, it immediately ...

Selecting cabinet one of first orders of business for Trudeau
One of the first orders of business for any new prime minister is picking a cabinet. Who is likely to make the cut?

Agile Analysis, Self-Selecting Teams, TDD & BDD in Methods & Tools Winter 2014 issue
... for software developers, testers and project managers – has just published its Winter 2014 issue that discusses Agile Analysis, Self-Selecting ...

Resources last updated: 12/9/2015 2:01:41 AM