Answered by:
Dropdownlist

Question
-
User-838109168 posted
In dropdownlist show the PatientID of table.
when we select the id then show the PatientName in the textbox on the behalf of PatientID
Monday, August 16, 2010 6:19 AM
Answers
-
User-68639941 posted
hi,
you can bind dropdown DataTextField with patientName and DatavalueField with patientId,
in dropdownselectedindexchanged event you can set the value to the textbox
DropDownList1.DataSource=dataSet; // or you can also use datareader
DropDownList1DataValueField="PatientName"; // i hope PatientName is unique else concatenate both (id+name) and bind
DropDownList1.DataTextField="PatientId";
DropDownList1.DataBind();protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
textBox.Text=DropDownList1.SelectedValue;
}Refer : http://www.codersource.net/asp-net/asp-net-articles/dropdownlist-in-asp-net.aspx
http://www.dbtutorials.com/advanced/populatingdropdown-csharp.aspx
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, August 16, 2010 7:39 AM -
User1224194097 posted
Load DropDownList with DataTextField with Patient ID and DataValueField as PatientName.
Set AutoPostBack="true" for the DropDownList and add an event Handler for SelectedIndexChanged Event.
Update TextBox text in the event handler
txtPatientName.Text=DropDownList1.SelectedItem.Text;
That should display Patient Name in the TextBox.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, August 16, 2010 7:41 AM
All replies
-
User-68639941 posted
hi,
you can bind dropdown DataTextField with patientName and DatavalueField with patientId,
in dropdownselectedindexchanged event you can set the value to the textbox
DropDownList1.DataSource=dataSet; // or you can also use datareader
DropDownList1DataValueField="PatientName"; // i hope PatientName is unique else concatenate both (id+name) and bind
DropDownList1.DataTextField="PatientId";
DropDownList1.DataBind();protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
textBox.Text=DropDownList1.SelectedValue;
}Refer : http://www.codersource.net/asp-net/asp-net-articles/dropdownlist-in-asp-net.aspx
http://www.dbtutorials.com/advanced/populatingdropdown-csharp.aspx
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, August 16, 2010 7:39 AM -
User1224194097 posted
Load DropDownList with DataTextField with Patient ID and DataValueField as PatientName.
Set AutoPostBack="true" for the DropDownList and add an event Handler for SelectedIndexChanged Event.
Update TextBox text in the event handler
txtPatientName.Text=DropDownList1.SelectedItem.Text;
That should display Patient Name in the TextBox.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, August 16, 2010 7:41 AM -
User-592147399 posted
Hi,
Load your dropdownlist DataTextField as patientName and DataValueField as PatientId.
ddl2.DataSource = dr;
ddl2.DataValueField = "PatientId";
ddl2.DataTextField = "PatientName";
ddl2.DataBind();
Regards,
M.Pradeeban
Monday, August 16, 2010 8:35 AM