| | |
regarding drpo down list
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2008
Posts: 37
Reputation:
Solved Threads: 0
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
I am getting an error at NewDepartment saying that NewDepartment is not declared.
Any help is greatly appreciated.
Thanks in advance,
Karthik.
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
ASP.NET Syntax (Toggle Plain Text)
Dim k As String If ddldept.SelectedItem = NewDepartment Then txtdept.Text = Visible k = txtdept.Text.ToString() ddldept.SelectedItem.Equals(k) End If
I am getting an error at NewDepartment saying that NewDepartment is not declared.
Any help is greatly appreciated.
Thanks in advance,
Karthik.
•
•
Join Date: Dec 2008
Posts: 37
Reputation:
Solved Threads: 0
Here is my code
Source Code:
Thank u
ASP.NET Syntax (Toggle Plain Text)
Dim k As String If (ddldept.SelectedItem.ToString() = "NewDepartment") Then txtdept.Visible = True k = txtdept.Text.ToString() ddldept.SelectedItem.Equals(k) End If
Source Code:
ASP.NET Syntax (Toggle Plain Text)
<asp:DropDownList 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>
•
•
Join Date: Dec 2008
Posts: 104
Reputation:
Solved Threads: 18
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
.aspx.vb
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
ASP.NET Syntax (Toggle Plain Text)
<asp:DropDownList 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> <asp:Button ID="Button2" runat="server" Text="Button" /></div> <asp:TextBox ID="TextBox1" Visible="false" Text="" runat="server"></asp:TextBox>
.aspx.vb
ASP.NET Syntax (Toggle Plain Text)
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click If (ddldept.SelectedItem.ToString() = "NewDepartment") Then TextBox1.Visible = True End If End Sub
Last edited by Aneesh_Argent; Dec 30th, 2008 at 8:38 am.
•
•
Join Date: Dec 2008
Posts: 104
Reputation:
Solved Threads: 18
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
.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
![]() |
Other Threads in the ASP.NET Forum
- Previous Thread: How to get an excel file while button click.
- Next Thread: Custom class object question
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol advice ajax alltypeofvideos asp asp.net bc30451 bottomasp.net browser businesslogiclayer button c# c#gridviewcolumn checkbox class click commonfunctions compatible confirmationcodegeneration content contenttype countryselector courier css dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deadlock development dgv dropdownlist dropdownmenu edit expose flash flv formatdecimal forms formview gridview homeedition iframe iis javascript jquery list listbox login menu microsoft mono mouse mssql multistepregistration nameisnotdeclared news numerical objects order panelmasterpagebuttoncontrols problem radio ratings rotatepage save schoolproject search security serializesmo.table silverlight smartcard sql sql-server sqlserver2005 suse textbox tracking unauthorized validation vb.net video videos virtualdirectory vista visual-studio visualstudio vs2008 web webarchitecture webdevelopemnt webservice wizard xml youareanotmemberofthedebuggerusers





