I need code for retrieve data from database to textbox when changing combox value.
Hi Sanila Pavithran,
There is no combo box control in Asp.net. Instead of this, there is dropdownlist control present. Use OnSelectedIndexChanged event of dropdownlist (your comboBox) and retrieve data from database to display into textbox. Let me show you with
sample example, modify it with your requirement.
sanilapavith...
0 Points
8 Posts
Reterieve data from database to text box when combo box value changes
Nov 11, 2012 05:31 AM|LINK
Hello
I am developing an application
I need code for retrieve data from database to textbox when changing combox value..
Pls consider my question and reply
chetan.sarod...
All-Star
65749 Points
11148 Posts
Re: Reterieve data from database to text box when combo box value changes
Nov 12, 2012 04:56 AM|LINK
Refer this
http://forums.asp.net/t/1735220.aspx/1
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
matifnadeem
Contributor
4692 Points
1107 Posts
Re: Reterieve data from database to text box when combo box value changes
Nov 12, 2012 05:49 AM|LINK
Hi Sanila Pavithran,
There is no combo box control in Asp.net. Instead of this, there is dropdownlist control present. Use OnSelectedIndexChanged event of dropdownlist (your comboBox) and retrieve data from database to display into textbox. Let me show you with sample example, modify it with your requirement.
ASPX CODE : ----------- <asp:DropDownList ID="NameDropDownList" runat="server" AppendDataBoundItems="True" AutoPostBack="True" DataTextField="EmployeeName" DataValueField="EmployeeID" Width="220px" OnSelectedIndexChanged="NameDropDownList_SelectedIndexChanged"> <asp:ListItem Selected="True" Value="-1">- Select -</asp:ListItem> </asp:DropDownList> CODE BEHIND : ------------- protected void NameDropDownList_SelectedIndexChanged(object sender, EventArgs s) { int employeeId = Convert.ToInt32(NameDropDownList.SelectedValue); if (employeeId > 0) { var getEmail = (from dbo.Employees e where e.EmployeeID == employeeId select e).ToList(); if (getEmail.Rows.Count > 0) { EmailTextBox.Text = getEmail.Rows[0]["EmailAddress"]; } } }Cheers
M Atif Nadeem
Mark as Answer if you got right thing
Read my blog | Follow me on LinkedIn