regarding drpo down list

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2008
Posts: 37
Reputation: kodingkarthik is an unknown quantity at this point 
Solved Threads: 0
kodingkarthik kodingkarthik is offline Offline
Light Poster

regarding drpo down list

 
0
  #1
Dec 30th, 2008
Hi all,

I am trying to select a value from drop down list and if the value is NewDepartment then a text box should be visible for adding a new value and that value must be populated in the drop down list also if the user selects the new value then that value should also be stored into the database.

How can we do that?
I did write few lines of code but i am getting errors.My code goes here
  1. Dim k As String
  2. If ddldept.SelectedItem = NewDepartment Then
  3. txtdept.Text = Visible
  4. k = txtdept.Text.ToString()
  5. ddldept.SelectedItem.Equals(k)
  6. End If

I am getting an error at NewDepartment saying that NewDepartment is not declared.

Any help is greatly appreciated.
Thanks in advance,
Karthik.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 104
Reputation: Aneesh_Argent is an unknown quantity at this point 
Solved Threads: 18
Aneesh_Argent Aneesh_Argent is offline Offline
Junior Poster

Re: regarding drpo down list

 
0
  #2
Dec 30th, 2008
Try this:

If (ddldept.SelectedItem.ToString() = "NewDepartment" ) Then
txtdept.Text = Visible
k = txtdept.Text.ToString()
ddldept.SelectedItem.Equals(k)
End If
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 37
Reputation: kodingkarthik is an unknown quantity at this point 
Solved Threads: 0
kodingkarthik kodingkarthik is offline Offline
Light Poster

Re: regarding drpo down list

 
0
  #3
Dec 30th, 2008
I think ther is a problem in the code i am not able to get the required o/p
like if i select the value the textbox should be visible but iti is not happenning
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 104
Reputation: Aneesh_Argent is an unknown quantity at this point 
Solved Threads: 18
Aneesh_Argent Aneesh_Argent is offline Offline
Junior Poster

Re: regarding drpo down list

 
0
  #4
Dec 30th, 2008
Are you sure about the spelling of the selected item. Is it "NewDepartment" with no spaces in between words?
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 37
Reputation: kodingkarthik is an unknown quantity at this point 
Solved Threads: 0
kodingkarthik kodingkarthik is offline Offline
Light Poster

Re: regarding drpo down list

 
0
  #5
Dec 30th, 2008
But i am not able to get the required o/p like i have to display a text box on selecting a specific value in the drop down list
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 104
Reputation: Aneesh_Argent is an unknown quantity at this point 
Solved Threads: 18
Aneesh_Argent Aneesh_Argent is offline Offline
Junior Poster

Re: regarding drpo down list

 
0
  #6
Dec 30th, 2008
Can you post your source code for the Dropdownlist
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 37
Reputation: kodingkarthik is an unknown quantity at this point 
Solved Threads: 0
kodingkarthik kodingkarthik is offline Offline
Light Poster

Re: regarding drpo down list

 
0
  #7
Dec 30th, 2008
Here is my code

  1. Dim k As String
  2. If (ddldept.SelectedItem.ToString() = "NewDepartment") Then
  3. txtdept.Visible = True
  4. k = txtdept.Text.ToString()
  5. ddldept.SelectedItem.Equals(k)
  6. End If

Source Code:

  1. <asp:DropDownList ID="ddldept" runat="server" Style="z-index: 131; left: 242px; position: absolute;
  2. top: 153px">
  3. <asp:ListItem>Solutions</asp:ListItem>
  4. <asp:ListItem>SA</asp:ListItem>
  5. <asp:ListItem>Training</asp:ListItem>
  6. <asp:ListItem>HR</asp:ListItem>
  7. <asp:ListItem>Finance</asp:ListItem>
  8. <asp:ListItem>Documentation</asp:ListItem>
  9. <asp:ListItem>Quality</asp:ListItem>
  10. <asp:ListItem>NewDepartment</asp:ListItem>
  11. </asp:DropDownList>
Thank u
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 104
Reputation: Aneesh_Argent is an unknown quantity at this point 
Solved Threads: 18
Aneesh_Argent Aneesh_Argent is offline Offline
Junior Poster

Re: regarding drpo down list

 
0
  #8
Dec 30th, 2008
This code is working fine for me:

If I select the item 'NewDepartment' and click the button the textbox is becoming visible. As you can see i have written the code in the button click event. Is this you are looking for?

.aspx
  1.  
  2. <asp:DropDownList ID="ddldept" runat="server" Style="z-index: 131; left: 242px; position: absolute;
  3. top: 153px">
  4. <asp:ListItem>Solutions</asp:ListItem>
  5. <asp:ListItem>SA</asp:ListItem>
  6. <asp:ListItem>Training</asp:ListItem>
  7. <asp:ListItem>HR</asp:ListItem>
  8. <asp:ListItem>Finance</asp:ListItem>
  9. <asp:ListItem>Documentation</asp:ListItem>
  10. <asp:ListItem>Quality</asp:ListItem>
  11. <asp:ListItem>NewDepartment</asp:ListItem>
  12. </asp:DropDownList>
  13.  
  14. <asp:Button ID="Button2" runat="server" Text="Button" /></div>
  15.  
  16.  
  17. <asp:TextBox ID="TextBox1" Visible="false" Text="" runat="server"></asp:TextBox>

.aspx.vb

  1. Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
  2. If (ddldept.SelectedItem.ToString() = "NewDepartment") Then
  3. TextBox1.Visible = True
  4. End If
  5. End Sub
Last edited by Aneesh_Argent; Dec 30th, 2008 at 8:38 am.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 37
Reputation: kodingkarthik is an unknown quantity at this point 
Solved Threads: 0
kodingkarthik kodingkarthik is offline Offline
Light Poster

Re: regarding drpo down list

 
0
  #9
Dec 30th, 2008
ya thts fine but u are using a button click event but i want dropdown list onselectionchanged event. i am not able to do that.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 104
Reputation: Aneesh_Argent is an unknown quantity at this point 
Solved Threads: 18
Aneesh_Argent Aneesh_Argent is offline Offline
Junior Poster

Re: regarding drpo down list

 
0
  #10
Dec 31st, 2008
Try this:

.aspx

<asp: DropDownList OnSelectedIndexChanged="ddldept_SelectedIndexChanged" AutoPostBack="true" ID="ddldept" runat="server" Style="z-index: 131; left: 242px; position: absolute;
top: 153px">
<asp:ListItem>Solutions</asp:ListItem>
<asp:ListItem>SA</asp:ListItem>
<asp:ListItem>Training</asp:ListItem>
<asp:ListItem>HR</asp:ListItem>
<asp:ListItem>Finance</asp:ListItem>
<asp:ListItem>Documentation</asp:ListItem>
<asp:ListItem>Quality</asp:ListItem>
<asp:ListItem>NewDepartment</asp:ListItem>
</asp: DropDownList>

.aspx.vb

Protected Sub ddldept_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddldept.SelectedIndexChanged
If (ddldept.SelectedItem.ToString() = "NewDepartment") Then
TextBox1.Visible = True
End If
End Sub
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the ASP.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC