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

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

Related

Updating Model inside of view

I've been working on a photography page for a while now. Now I've tried to create a page on which user will upload photos to database.
I wanted to give the user an option of selecting photo categories on the create/upload page using checkboxes. I wanted to use a viewmodel with list of categoryview models which would represent the checkboxes.
Now the tricky part that i need some help with is how do I allow user to dynamically add new categories (if he needs to) on the same page. So how would i add new values into the list of categories on view.
Only thing that comes to my mind is to create an ajax post that would call a method that would create the new category in the database. Then i could append a new checkbox representing that category, But then i do not know how i would send that category in the list of categories in viewmodel without refreshing current page. Is this even possible?
If any1 has any ideas how to start on this I would be grateful.

detailsview does not show all data in one page

I am trying to show the sum of totals for different kind of invoices on a web page.
I am using detailsview control, however it does not show all the data in one page. When I enable paging the other types of invoices can be seen on 2nd and 3rd pages.
My SQL command is:
SELECT CARI_HESAP_KODU, FATURA_TURU, SUM(KDV_MATRAHI) AS TUTAR FROM LNX_STD_6_016_01_SLSINVOICES WHERE CARI_HESAP_KODU=#mKodu GROUP BY FATURA_TURU, CARI_HESAP_KODU
When I run it from SQL I get the proper results:
But when I run the page and test detailsview I get:
So I have two questions:
1. Is it possible to show the results as columns (as in SQL view) instead of rows?
2. Is it possible to show all the records in one page?
Thanks in advance.
As stated in the comments by Esko, the details view only shows one record at a time. The details and Grid views are fast easy ways to display data, however if you wanted to customize how data is displayed, a more generic repeater would be the next logical choice, you would just have to do the formatting yourself.
Check out his article or google "asp.net repeater":
https://msdn.microsoft.com/en-us/library/zzx23804(v=vs.85).aspx
When I used to program in web forms a lot, I used repeaters even when a details or grid view would have done the job, because they are much more flexible and easier to maintain when someone asks for changes.
Cheers.

Mark items in Listbox 2 from selection in ListBox 1

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.

In ASP.NET MVC4 - I need to edit a record and add many (1 to many) sub-records to it (while in Edit mode on the top level record)

Here's my list of data:
Going into Edit mode on the first record:
Here on this Edit page, I need to add multiple "Departments" to this particular contact record. I have a 1 to many relationship (1 contact record to many department records).
Ideally, I'd like to have something like an "Add New Department" button, where the user clicks on it and it will create form fields that tie to department. User fills them out, clicks Save, and has the option to again add another department by way of "Add New Department".
I'm not exactly sure where to start - how can I go about accomplishing this?
That job can't be achieved only by mvc stuff. To achieve your goal, you need to do some extra works by jquery, ajax and partial views.
The main idea is to have a partial view to representing a detail row (when in create phase) and another partial view for getting all details of a master entity (when in edit phase).
A brief example is here. A full howto is here.

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