Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have 3 drop down lists and one text box in my demo.aspx page those are

Type(chit,Investment,scheme,emi)drop down list
Amount(1lac,2lac,3lac,4lac)drop down list
NoOfMonths(12,24,36,48)
MonthlyPay(it should come automatically based on above selection)textbox


i have the default values for above i.e

Type Amount NumberofMonths Monthlypay
Chit 1lac 12 9800
Chit 1Lac 24 5800
Chit 1Lac 36 4500
....
....
....
if i select (drop downs)continuously chit,1lac,12months then automatically show monthly pay(text box) is 9800

can you please suggest me how can i do this
Posted

1 solution

check Creating Cascading DropDownLists in ASP.Net[^]
you will learn how to load data to child dropdown list when parent dropdown list changed.
when last dropdown list changed you can read monthplay value based on selected values of previous dropdown lists from your database and set the value as Text property of monthplay TextBox
 
Share this answer
 
Comments
Member 11382784 4-Jul-15 6:30am    
Thanks for your help.
how to bind the data to textbox instead of dropdownlist


ddlmonthlypay.Items.Clear();
ddlmonthlypay.AppendDataBoundItems = true;
String strConnString = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
String strQuery = "select ID, MonthlyPay from Tmonthlypay where NoOfMonthsID=@NoOfMonthsID";
SqlConnection con = new SqlConnection(strConnString);
SqlCommand cmd = new SqlCommand();
cmd.Parameters.AddWithValue("@NoOfMonthsID", ddlNoOfMonths.SelectedItem.Value);
cmd.CommandType = CommandType.Text;
cmd.CommandText = strQuery;
cmd.Connection = con;
try
{
con.Open();
ddlmonthlypay.DataSource = cmd.ExecuteReader();
ddlmonthlypay.DataTextField = "MonthlyPay";
ddlmonthlypay.DataValueField = "ID";
ddlmonthlypay.DataBind();
if (ddlmonthlypay.Items.Count > 1)
{
ddlmonthlypay.Enabled = true;
}
else
{
ddlmonthlypay.Enabled = false;
}


how to bind the result to text box

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900