| | |
Binding Data to text box
Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Sep 2009
Posts: 21
Reputation:
Solved Threads: 1
Hi friends,
I have created a form with a dropdown list and a text box and i have a table named customer with fields cid and name in database.
I successfully binded the cid column to dropdown list.now my problem is i want to bind the name into the text box based on cid selected in drop down list.
Please helpme doing this.
I need it very urgent.
Thanks.
I have created a form with a dropdown list and a text box and i have a table named customer with fields cid and name in database.
I successfully binded the cid column to dropdown list.now my problem is i want to bind the name into the text box based on cid selected in drop down list.
Please helpme doing this.
I need it very urgent.
Thanks.
•
•
Join Date: Sep 2007
Posts: 66
Reputation:
Solved Threads: 12
Hello dear
You can use select_IndexChangeEvent Like this...
And make sure Your Dropdownlist must have Autopostback property = true
Mark as solved if it helps you!!!
You can use select_IndexChangeEvent Like this...
ASP.NET Syntax (Toggle Plain Text)
Protected Sub MyDropDownList_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyDropDownList.SelectedIndexChanged Mytextbox.text = MyDropDownList.selectedItem.text End Sub
Mark as solved if it helps you!!!
•
•
Join Date: Aug 2009
Posts: 19
Reputation:
Solved Threads: 2
Hi,
You might have stored the name of the customer in the database.
Just write a query to fetch the name from the table and add it to the textbox.
protected void dropdownlst_selectectchange(object s, evetntargs s)
{
string str=dropdownlist1.selecteditem.text;
string sql="select name from customer where custid="+str;
sqlcommand cmd=new sqlcommand(sql,connectionstring)
sqldatareader dr=cmd.executereader()
while(dr.read())
{
textbox1.text=dr[0].tostring();
}
}
You might have stored the name of the customer in the database.
Just write a query to fetch the name from the table and add it to the textbox.
protected void dropdownlst_selectectchange(object s, evetntargs s)
{
string str=dropdownlist1.selecteditem.text;
string sql="select name from customer where custid="+str;
sqlcommand cmd=new sqlcommand(sql,connectionstring)
sqldatareader dr=cmd.executereader()
while(dr.read())
{
textbox1.text=dr[0].tostring();
}
}
•
•
Join Date: Sep 2009
Posts: 21
Reputation:
Solved Threads: 1
•
•
•
•
Hi,
You might have stored the name of the customer in the database.
Just write a query to fetch the name from the table and add it to the textbox.
protected void dropdownlst_selectectchange(object s, evetntargs s)
{
string str=dropdownlist1.selecteditem.text;
string sql="select name from customer where custid="+str;
sqlcommand cmd=new sqlcommand(sql,connectionstring)
sqldatareader dr=cmd.executereader()
while(dr.read())
{
textbox1.text=dr[0].tostring();
}
}
Now i have another problem that i am not able to select other cid from the drop down list.If i select another "cid" from the DDL also it is not effecting.It is always displaying the first item of the list.
How to solve this.please help me.
![]() |
Other Threads in the ASP.NET Forum
- Previous Thread: deploy unsigned windows forms control (activex) for intranet use
- Next Thread: Smo.StoredProcedure Help!
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol advice ajax appliances asp asp.net beginner bottomasp.net box browser businesslogiclayer button c# c#gridviewcolumn cac checkbox class click compatible confirmationcodegeneration content contenttype control countryselector courier css database datagrid datagridview datalist deadlock deployment development dgv dialog dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv forms gridview gudi homeedition iframe iis javascript jquery list menu mono mssql multistepregistration nameisnotdeclared novell objects opera order problem ratings redirect registration relationaldatabases reportemail rotatepage search security serializesmo.table sessionvariables silverlight smartcard smoobjects software sql ssl tracking treeview validatedate validation vb.net virtualdirectory vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopment wizard xml xsl





ropDownList ID="DropDownList1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="dropdownlst_selectectchange"> 