Click here to Skip to main content
15,843,200 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
How to bind textbox from DropdownList statically without using database in ASP NET

What I have tried:

C#
public partial class Pay : System.Web.UI.Page
{
    int a = 600; 
    int b = 500;
    int c = 800;
    string ph;
    
    protected void Button2_Click2(object sender, EventArgs e)
    {
        ph = DropDownList2.SelectedItem.Text;

        if (ph == "physics")
        {
            TextBox9.Text = a.ToString();
        }
        else if (ph == "chemistry")
        {
            TextBox9.Text = b.ToString();
        }
        else if (ph == "maths")
        {
            TextBox9.Text = c.ToString();
        }
    }
}
Posted
Updated 21-Oct-22 0:46am
v2
Comments
Richard Deeming 21-Oct-22 5:46am    
You've forgotten to ask a question.
CHill60 21-Oct-22 13:02pm    
What is wrong with your code?

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