Mark items in Listbox 2 from selection in ListBox 1 - c#

I have two ListBox with some items in each. I have three tables, lets say, company, employee, company_employee
I populate the first ListBox with the company, second ListBox with employee. What I want is to select a company and when I do that, select what employee's that are connected to that company.
How can I do this with asp.net MVC 4? I thought of a ajax-solution to get the records in company_employee depending on my first listbox selection id, but im not sure how to do this with asp.net.
Any suggestions to lead me forward?
Best regards,
me.

Use a jquery event triggered on a change of your first listbox that calls a webservice that will return a custom collection(employees) of type employee, this method will take in the country id perhaps . Bind that collection to a control. If you're expecting it all on a plate sorry but that is the way forward you can break this down and learn how to do each step.

Related

Associative Selection from the Table in to Asp.net application form

I have one table in a de-normalized form Named 'Category Classification' in which i have 4 fields like Category, Subcategory, Brand and Company.
I want to develop a searching criteria on asp.net in which the scenario would be:
If i select category from the drop down, It should automatically show the subcategories associated with that selected category in the next drop down of the subcategory.
Same goes for the brand as well. If i select the subcategory, The grid should appear with the check boxes of the related brands of that selected subcategory.
The screen shot of the said criteria is attached along.
I need the logic behind the denormalized database like Microsoft excel has that functionality which i need to implement on asp.net.
Your help would be highly appreciated.
To achieve the linked drop down lists goal, here is a link that explains the issue in details and solve it without using Jquery and Ajax
Creating Cascading DropDownLists is ASP.Net

Win8 Grid template how to hide all items from groupeditems page?

I'm new about win8 and developing visual studio.
I use Grid template and i wondering...
How to hide all items, but not Group name and group box.. I have too many items and i do want all item to this page. When click group box or title, find groupdetail page and there is all this group items?
Thanks.
The Grid template won't display all your items on the GroupedItemsPage. It uses the TopItems property in the view model to show at most 12 items. If you look in SampleDataSources.cs you'll see code (with a hard coded value - sigh) of 12 in ItemsCollectionChanged.
So, you could modify the 12 value if you want fewer, or if you want NO items to appear on the GroupedItemsPage, remove the GridView and perhaps replace it with a ListView whose ItemsSource is the group headers, but that's a bit more work and a change in the UI, which by all means is fine to do.
These templates are just a starting point, and we'd encourage you to make changes that make sense to provide the best user experience for your app.

WinRT ListView grouping on multiple levels

I have a project where I have a list of appointments:
Appointment:
Name
City
Street
I want to display those in a ListView, and group them on 2 levels, first by city, and then by street. I also want to be able to collapse the items on both levels and style the header differently.
Is something like that possible in a ListView in WinRT?
I thought about using a ListView in a ListView. But that's not possible because I want to use single selection mode. Or is there some way I can enforce this?
Personally I would keep it simple.
In the Cineworld app I created, in cinema details xaml page, I give users options to view
* Films showing today (grouped by first char)
* Films grouped by date
* All films listed (grouped by first char).
These were all very different options and I settled on a combination of radio button and multiple grouped listview (within semantic zoom).
The solution has worked well so far.

How to make listview items clickable in c#

I have a listview that is connected to a datasource. When I view the project in a browser, the listview is populated with data from the Northwind database. I just have the CustomerID and ContactTitle columns displayed. I want to be able to click on the CustomerID and then display the rest of the information about that particular customer. I've searched and searched and searched and tried a ton of different things but I just can't figure out how to make the CustomerID clickable. I am using c# and ASP.NET. Any help would be greatly appreciated.
You want to create a itemTemplate that contains various controls and bind the columns of your datasource to those controls. For the field in question you want to make sure you select a "clickable" control. like a link, button or even a div, and then create a handler for that click event. A good example of such a thing can be found in MSDN here: http://msdn.microsoft.com/en-us/magazine/cc337898.aspx
Do your list items contain li's? Whatever tag you use, you would use the javascript onclick event on each li to initiate whatever action you require.
If you need to retrieve customer data you could initiate a postback from your javascript to retrieve the data and display the customer details.

Creating ascx dynamically and adding controls to it

I am a beginner in asp.net(C#) and stuck in an important point.
I have a dropdown list on my homepage which users select a category.
After selecting the category, user will fill a form which has related controls to that category in it.
As I have many categories, I just want to have single ascx page and adding controls to it dynamically according to the user choice.
For example: One chose Telephone category, he will face a form having drop down lists asking, what brand? what color?
And one chose, book category, he will face drop down lists asking which type? howmany pages?
So 1 ascx must do my work at runtime done as I have alot of categories.
I am going to take these criterias from a database table which has CategoryID and Criteria colomns.
And if I can do that, will it be possible to add field validators to these dynamically created controls.
Nearly all controls are drop down list, if this helps.
Any help would be highly appreciated..
Thanks alot
You can add an asp:placeholder Or literal control to your page and then populate all the controls programatically. Altough you will have to take special care to make sure the control state and view state are correct at all times.
Here's an example on how to do it
https://web.archive.org/web/20211020131055/https://www.4guysfromrolla.com/articles/081402-1.aspx

Categories

Resources