hello, I am a beginner in ASP.NET and I really need your help.

I have a simple database, I want to show list of names (customers) in a dropdown list and, according to what I click on the dropdown list, to get the table updated below... with data corresponding to dropdown list selection.

I know there is GridView, and I know everything can be done automatically, but I want to learn coding and I want to do it myself... coz when I do it automatically it doesnt show any code so I can ponder on it and learn.

Please help
thanks

Recommended Answers

All 4 Replies

ok, so what exactly is the question? I understand what you're wanting to accomplish, but where are you in the process? What have you tried so far? What are your results compared to what you expect? Are you getting any errors?

thanks for reply.
I already made one dropdown list which is pulling list of customers. It is ok. here is the code of that:

`protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["konekcija"].ToString());
        SqlCommand cmd = new SqlCommand("SELECT ID, CustomerName+' '+CustomerSurname as Customer FROM tblCustomers",conn);

        conn.Open();
        SqlDataReader dr = cmd.ExecuteReader();
        drp.DataSource = dr;
        drp.DataTextField = "Customer";
        drp.DataValueField = "ID";
        drp.DataBind();
        conn.Close();

    }

Now, what I want to do is to make a table showing data relative to what I select in dropdown list.
So if I change, if I select something else in the dropdown list, the table also changes the data to show the data related to the customer selected in the dropdown list.

The easiest way to accomplish this is to do it automatically. But I would like to do it by myself...
How do I do it? I need some advices.

Thanks

Several ways you can do this...one is that enable the dropdownlist to autopost back. On a page load which is a post back you can check to see what has been selected and then do something based on that information.

I tried autopostback=true and dropdownlist didnt work at all then

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.