Last post Jan 12, 2011 07:16 PM by sjnaughton
Jan 03, 2011 01:22 PM|PeterSkellern|LINK
Thank you. I am using custom FieldTemplates in order to display only valid combinations between two tables, not all stored records. I have seen some of this in the hierarchical cascading solutions
presented in C#Bits, however, cascading goes more into showing all records matching a predecessor combo box selection than filtering the records already displayed
There are cases in which you need to get additional filtering as to get just "some" records which might be valid during a specific date/time and/or items combination. For instance, you can have
all your ADIDAS shoe styles listed in a table but you want to give away only those pertaining to the "Rafael Nadal" line 50% off during January 8 and 9 only. In this case scenario you will need to filter your data accordingly because you have just received
the newer style "Roger Federer" which is quite expensive and new and you won't allow to sell it at half its price, yet
The problem I am facing is that custom field templates do their job fine in its Insertion Mode but only the first time you got the record displayed. Remember that you inherit the values filtered
from List.aspx and those selections are the ones you got firts if you choose to go into Insert mode
If you try to choose different selections from your combo boxes the remaining ones will keep its previous data and won't be refreshed as to display newer proper combinations. Any idea on how to
make those other filters "sense" the changes made?. Thank you
Jan 04, 2011 03:06 AM|PeterSkellern|LINK
Thank you. It seems that I must be looking for something called delegates but it is something really confusing and there is not much information about implementing or activating them or firing events when using custom controls
The case I have to solve is this:
If I had two dropdownlists fieldtemplates custom controls and I want the second dropdownlist to be filled with data after selecting a value from the first dropdownlist, but not all records stored in my database, neither
do I need to display all the children records of a parent record but just "some" of them
My cardinality will be refiltered and reduced from "many" to "some" depending on business directives for selling our products. Those directives will be mostly availability of on sales pricings depending on specifics dates:
Christmas, Valentines Day, mothers’ day, Easter, etc.
Jan 04, 2011 11:56 AM|sjnaughton|LINK
Hi Peter, this sounds like you want my old cascading FT's see
Cascading or Dependant Field Templates for ASP.Net... I have not done an update for DD4 as yet but it should mostly work.
Dynamic Data 4
Jan 05, 2011 06:43 AM|PeterSkellern|LINK
Thank you. I am wishing not to depend on hard wiring my controls as it seems it should be in my MetaData file for cascading them
I have created two custom controls and I call them from within my MetaData file by means of the UIHint directive. I would like to fill the second one, which is dropdownlist, by reacting to the OnSelectedIndexChanged event of the first one. My question is:
how can I just activate the second one?
Jan 05, 2011 08:22 AM|sjnaughton|LINK
Again Peter, how to do that is in the above articel and it's predicessors.
Jan 05, 2011 09:00 AM|PeterSkellern|LINK
Thank you. I will look deeper into it. Please don't feel as am refusing to use your solutions it is just that I considered that the solution to my problem could be a little simpler. Please
be advised that any help from you is always very well welcomed, extremely
Jan 05, 2011 09:16 AM|PeterSkellern|LINK
Thank you. I must also add that when I said something simpler I was expecting to find a solution like CustomUserControl2.Activate.Equals(“true”) or something like that, now I can see that it is not that easy at all
Jan 05, 2011 12:10 PM|PeterSkellern|LINK
Thank you. Don't you need to register the custom controls in the Insert page before using them?
Jan 05, 2011 01:05 PM|sjnaughton|LINK
Peter, in my solution with the filters of field templates the field templates discover each other (each child discovers it's parent using my FindControlRecursive and GetParent<FormView> extension methods. The important thing to note is the if you have three
then they must appear in the that order of the form so that Manufacturer is instantiated before Model and Model before Style.
Hope that makes sense.
Jan 06, 2011 11:27 AM|PeterSkellern|LINK
Thank you. I have tried using your solution inside mine. I have probably made some mistakes in combining my files and yours. I have checked namespaces and I have corrected them but when it comes
to debugging I got a lot of errors and a message saying that the code has been changed from its original version so my breakpoints can't be reached. In general terms I haven't made the solution to work correctly.
Could there be a way for you indicating what files to copy and where as not to use an additional \bin folder because some of those references are already contained in another class and that
might as well could be a potential cause or errors? I will like to include in my web site just the very necessary files. Will that be a problem for you I apologize?
Jan 06, 2011 09:08 PM|PeterSkellern|LINK
Thank you. I finally could resolve the mess of files that I have created when copying your files. Now I have the problem that your custom controls don’t support entity navigation properties but just native kind of data as
Int32, etc. Is there a newer version that might be used as to achieve this kind of cascading?
Jan 07, 2011 03:26 AM|PeterSkellern|LINK
Thank you. I am trying to go ahead with the cascading thing. I suppose that I could rather use your newer version of your solution
I have already copied tese files from your from your model DD_EF_CascadingFiltersAndFields in my web site. I put them under the App_Code folder
I changed the namespace of all those .cs files to DD_CascadingFiltersAndFields and copied the file ForeignKey_Edit.ascx with is corresponding ForeignKey_Edit.ascx.cs into my FieldTemplates folder
I am getting the following error:
Error 1 Could not load type 'ForeignKey_EditField'
I have left the DD_CascadingFiltersAndFields in the file. Nothing
I have eliminated the namespace from the file and have added a reference to the DD_CascadingFiltersAndFields namespace. Nothing
Don't know what to do in order to have the Inherit issue solved or having working any of your solutions to the cascading situation. Thank you
Jan 07, 2011 09:50 AM|PeterSkellern|LINK
Thank you. Needing a little help here. Please
Jan 07, 2011 11:16 AM|sjnaughton|LINK
Where in your web site/web application project have you put the files?
Jan 07, 2011 11:45 AM|PeterSkellern|LINK
Thank you. I put all 11 .cs files (under my App_Code folder web site.
I put ForeignKey_Edit.ascx under FieldTemplates.
I changed all .cs 11 files namespace to the same namespace of the global.asx file which is the same of my .edmx file and my MetaData file.
The error message says: Could not load type 'ForeignKey_EditField'.
I changed this line
<%@ Control Language="C#" CodeBehind="ForeignKey_Edit.ascx.cs"
<%@ Control Language="C#" CodeBehind="ForeignKey_Edit.ascx.cs"
I also eliminated the namespace from the ForeignKey_Edit.ascx
I have made all this changes trying the model to work. It didn't as it came from the .zip file of the C#Bits site. I know for sure I am doing something wrong
Jan 07, 2011 11:52 AM|sjnaughton|LINK
You will need to change
<%@ Control Language="C#" CodeBehind="ForeignKey_Edit.ascx.cs"
<%@ Control Language="C#" CodeFile="ForeignKey_Edit.ascx.cs"
Changing CodeBehine to CodeFile.
Jan 07, 2011 12:08 PM|PeterSkellern|LINK
Thank you. It did it!
Jan 07, 2011 12:18 PM|PeterSkellern|LINK
Thank you and sorry. I wasn't using s1633Model in my ForeignKey_EditField too. Huge mistake. Thank you. I will test now how your solution works now in my web site. Again, thank you a thousand times
Jan 07, 2011 04:09 PM|sjnaughton|LINK
Your welcome [:)]
Jan 09, 2011 03:53 PM|PeterSkellern|LINK
Thank you. I am working with your cascading solution inside my application but I have seen a couple of things that, if you consider them to be plausible, could as well improve behavior and performance for this kind of control
1) It should be allowed to set some initial values as to avoid the control to be filling over and over all those controls that you don’t really want to be populated all the time and that you want them to remain unchanged. You could as well allow them to be
repopulated only if there is a postback happening for that control (selected index changed)
2) It will also be good if the last run of population, the one pertaining to the last children control, shouldn’t be made because it has already been populated when you chose a value from the previous dropdownlist, call it its father control
I am saying this because it seems to me that any go-and-went to gather values from the server should be avoided and while debugging I have seen that this happens sometimes as it usually happens with all DD reruns in its most intrinsic behavior
In number (2) I think I have made a couple of mistakes in my own implementation. I would like to say sorry for having written my coment too much a priori
I am just making an observation of something which I am not capable of doing myself so rather that criticizing I am mostly asking for help
Jan 10, 2011 11:14 AM|PeterSkellern|LINK
Thank you. In number (2) I think I have made a couple of mistakes in my own implementation. I would like to say sorry for having written my coment too much a priori
Jan 10, 2011 01:26 PM|PeterSkellern|LINK
Thank you. I am in awe! After debugging trough the many programs your solution has for cascading I am still amazed on how much code has been written. I still have the doubt if there is a simpler solution. Sorry again, I am just asking. I wouldn’t like to
be so reiterative about this. I need to have two customized controls which must be filtered first in accordance to a Session variable that determines the type of user accessing the system. This is done in my own way so I have populated them correctly until
now. No problem up to this point
Then I need to combine the behavior of the two custom FieldTemplates .ascx files that I have created. The second filter must be populated in accordance to the selection chosen in the first dropdownlist. My two custom controls are simple: a dropdownlist plus
an sql datasource for each one. I still think that there should be an easier way for handling the OnSelectedIndexChanged event of the first dropdownlist as to trigger a delegate to activate the second dropdownlist and populate it accordingly which could be
a kind of where clause for the second dropdownlist. I have been studying delegates but I have not found a way of activating the second dropdownlist by triggering it from the first dropdownlist. I want to have the two custom controls apart
Jan 12, 2011 08:10 AM|sjnaughton|LINK
Hi Peter, regarding
I still think that there should be an easier way for handling the OnSelectedIndexChanged event of the first dropdownlist as to trigger a delegate to activate the second dropdownlist and populate it accordingly which could be a kind of where clause for the second
The issue for me is to make what I wrote work with DD not standard web forms you could do everything in the pages code behind if you wanted but the code would not be reusable or easy to maintain.
I still don't understand what you want to do really other than pre filter one of the cascading field templates with a session value, I have done similar many times with my old cascade field templates. I find that using my newer cascading field template makes
the DB simpler, not so many relationships back to the same tables.
Jan 12, 2011 02:00 PM|PeterSkellern|LINK
Jan 12, 2011 02:01 PM|PeterSkellern|LINK
Thank you. I don't even understand myself. Sorry. For my Session pre filtering I have just added a where condition inside the basic 4 page templates. I am not saying that your model doesn't work, it does marvelously but it doesn't work for me as it comes
in the .zip files.I have to make further adjustments to it so I need to migrate its code into my own application. Your models works fine one at a time but they come with some additional code and dlls that is a little confusing to combine and they had given
me some troubles when combining them together. So my real problem is that I have to go a lot deeper into your code as to understand it, which is obviously a difficult task for me so I also look for a kind of simpler implementation that might as well work for
me and that I can understand. Thank you again and I won’t longer insist on this matter
Jan 12, 2011 07:16 PM|sjnaughton|LINK
Hi Peter, I will try to make it easyer to understand when I upgrade the article to .Net 4 and DD4.