0

I'm new to asp.net. I'm trying to create two linked dropdownlist i.e if first one is changed then the content of the second list should change accordingly. Also, based on those selections I want to display a table of data(please suggest what to use listview,gridview or repeater). My database is in mysql.using c#

5
  • i dont know how to do it. i mean i can create normal dropdownlist.As i said am new in this.i mean am switching from php,this is quite complicated. Commented Aug 19, 2012 at 14:43
  • 1
    why don't you pick a book or search for a tutorial online and learn Asp.Net Commented Aug 19, 2012 at 14:46
  • i did search a lot of them.first i had huge problem with mysql connection through c# it got solved after a lot of research ,had to waste quite alot of time.So i thought that i should ask here which is better coz that way i'd save some time and get some help from better answers Commented Aug 19, 2012 at 14:51
  • Spending time on searching for answers is NEVER a waste of time! If you think otherwise, maybe reconsider your decision on becoming a programmer. Commented Aug 19, 2012 at 14:52
  • okay i didn't waste time but i wanted to complete the job at hand. Commented Aug 19, 2012 at 14:56

2 Answers 2

1

Sentence "I'm newbie" doesn't matter here, because principles are all the same. You want to create two linked dropdownlists. So do it.

What would you do then in php? You guess right, do an ajax call to the server.

Here you have multiple options to choose from. Since you're comming from php background, I'd suggest using jquery.ajax to make the call. So you'd create the first dropdownlist with the values you need and hook the event using jquery, to handle when the user changes the selected value. Make the call using jquery to the web service with the selected value. You receive an answer from a webservice (search for tutorials, there are plenty of them on the web) and use the jquery again, this time to populate the second dropdownlist.

Sign up to request clarification or add additional context in comments.

2 Comments

I got this.can you tell me what to use to display a table of data,from gridview ,listview and repeater>
@Fash, that's a completely different question :-) Normally I wouldn't even bother answering, but I'll do one exception to point you to the right direction. Every one of those is suitable for a different scenario. Do a little research on the topic, see some examples what each of them can/can't do and pick based on your needs. For traditional tables I like to use GridView, while for a gallery or something like that I like to define my own layout using ListView. But that's just me and there is more to it to make a final decision.
0

You basically need to do something like this:

<asp:DropDownList ID="DDL1" AutoPostBack="true" runat="server" OnSelectedIndexChanged="DDL1_SelectedIndexChanged">
</asp:DropDownList>

In the code-behind, you basically do the binding for your second drop down list in the method called DDL1_SelectedIndexChanged (ie after someone changes the selection in the first drop down list)

protected void DDL1_SelectedIndexChanged(object sender, EventArgs e)
{
  // databind for second drop down list
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.