开发者

Display Data Based on Drop Down List

开发者 https://www.devze.com 2023-03-25 03:41 出处:网络
How would I go about using c# and ASP.NET (or Javascript if need be) to have my drop down lists change something like a div on the page. Basically I want it to populate a div with certain data.Either

How would I go about using c# and ASP.NET (or Javascript if need be) to have my drop down lists change something like a div on the page. Basically I want it to populate a div with certain data.Either from a SQL or XML Data Source. I have places I wanted listed, s开发者_Go百科o I'm assuming I'm going to need to put each place in with the tags that it may contain.


I would use jQuery, or some other javascript library, to hook up a listener to your dropdown and when the value changes I would make a request to some services or where you get your data from.


If you're using asp.net, then it's really straight-forward.

1) put a <asp:label> or <asp:literal> in your div.
2) in your designer, double-click your dropdownlist -- this will take you to the code-behind for the dropdown's onselecteditemchanged event.
3) Call your data, and assign it to the label. Ex.: ...me.myLabel.text = myreader("myfield"), or some more complicated html you've assembled, or what have you.

0

精彩评论

暂无评论...
验证码 换一张
取 消