locked
Custom Field Template won't associate with Column / foreign Key edit is not using edit version? RRS feed

  • Question

  • User1184604244 posted

    Ok so i have two problems here. This is a repost from this post here: http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/f504d960-2998-4dc8-acd7-d327e5f42499/#f504d960-2998-4dc8-acd7-d327e5f42499

    Please read above and post responses to that one here or their, doesn't matter much to me really.

    My main problem is that I'm unable to set a custom field template to associate with a specific column in my database.

    New problem i'm having is that I have a foreign key reference that has a field in the row i'm trying to edit, but instead of giving me a drop down box it's giving me the hyperlink button still even in the edit form. What things do I need to do to make it use the drop down box of the foreignKey_edit.aspx?

    Please be patient i'm very new to the EF framework and scaffold models.

    Tyler

    Monday, March 19, 2012 3:37 PM

All replies

  • User-330204900 posted

    well the first issue is you can't do the update of the undelying data except in the Extract values method please see the defaul Boolean_Edit field template.

    Tuesday, March 20, 2012 12:39 PM
  • User1184604244 posted

    well the first issue is you can't do the update of the undelying data except in the Extract values method please see the defaul Boolean_Edit field template.

    So what about the rest? The foreign Key edit template shows that it should be a drop down menu when editing it, but it does not do this on the default details edit page. It only shows the link to the details page of the foreign key reference.

    Please forgive me as I stated i'm very new to this stuff. What you mean by the extract values method? Are you saying that the only thing I'll be able to do is view the data? I already have a working method to update the boolean value it's just a matter of setting this custom field template to this column so it forces it away from the text box default. Right now we edited the textbox default (textbox_edit) to use this method if the column.name value is the value of the column for the boolean reference. It properly updates the row information without problem, but I'm pretty anal about my code. I'd like it to be using the proper field template for that column instead of hacking my way into the textbox value to only perform certain functions for specific columns. IMO that's not good practise.

    So as far as "You can't do this" thats not accurate. We already have it working. It's just a matter of making it go into the customized field template I created for those columns. They won't associate properly with the customized field template I setup. It basically ignores it and always goes to the default textbox field templates instead.

    I figure if we resolve the above, I'll know how to do the same for the foreignKey_edit template and force a new custom field template on those columns also.

    Wednesday, March 21, 2012 1:36 PM
  • User1184604244 posted

    Ok so i just did a test:

    I added labels to the various foreignKey.aspx pages. On the details page I put a label that says "details" and the _edit.aspx i put in a label that says "edit".

    I load the grid view, i see details
    I load the details page, i see details.
    I load the edit page, i see details.
    I load the insert new item page, I see Edit.

    Correct me if i'm wrong but shouldn't the insert new item page use the _Insert.aspx page and if i'm on the edit page shouldn't it be using the _edit.aspx field template??

    To me this looks like a bug in the scaffolding framework. But maybe someone can shed some light on this behavior for me and how I can override how it functions.

    Wednesday, March 21, 2012 2:40 PM
  • User-330204900 posted

    With field templates it uses the _Edit if there is not _Insert field template so using UIHint

    [UIHint("Custom")]

    in a field would get you

    Custom.ascx for Read-Only

    Custom_Edit for Edit or Insert if no _Insert field template available

    Custom_Insert if present only used for Insert mode.

    Wednesday, March 21, 2012 8:05 PM
  • User1184604244 posted

    With field templates it uses the _Edit if there is not _Insert field template so using UIHint

    [UIHint("Custom")]

    in a field would get you

    Custom.ascx for Read-Only

    Custom_Edit for Edit or Insert if no _Insert field template available

    Custom_Insert if present only used for Insert mode.

    ok I watched a video link from pluralsight you put in another forum post, very helpful indeed. Most i knew but there were a few new things like jQuery I had never used before that were helpful.

    With this UIHint I've actually done that before if you look at my code at the link posted at the top of the thread. They moved my thread so it may not be good. If not let me know.

    I think the problem i'm having is the UIHint option isn't being used from the custom.aspx field template I made. Also, how do I associate the foreignKey values? Should I just copy and paste what's in the foreignKey.aspx and modify those to what I need?

    Wednesday, March 21, 2012 9:14 PM
  • User1184604244 posted

    additionally, the foreignKey_edit.aspx does not work for some reason. It only shows up in the insert and not the edit pages. So I know the control works, but for some reason it uses the details version of the foreignKey.aspx instead of foreignKey_Edit.aspx in the edit page. Any idea why it would do that?

    Wednesday, March 21, 2012 9:24 PM
  • User-330204900 posted

    additionally, the foreignKey_edit.aspx does not work for some reason. It only shows up in the insert and not the edit pages. So I know the control works, but for some reason it uses the details version of the foreignKey.aspx instead of foreignKey_Edit.aspx in the edit page. Any idea why it would do that?

    This works out of the box for vanilla projects so all I can think is you have changed something in your project to cause this issue.

    As far your main issue is concerned the above could be related.

    Thursday, March 22, 2012 6:57 AM
  • User1184604244 posted

    This works out of the box for vanilla projects so all I can think is you have changed something in your project to cause this issue.

    As far your main issue is concerned the above could be related.

    I'll try to create a new site and see if it replicates on the same database. Would the fact that I built the site as a web application vs a website matter?

    Thursday, March 22, 2012 10:48 AM
  • User-330204900 posted

    Would the fact that I built the site as a web application vs a website matter?
    no it should maker no difference :) I woudl try using a DB Like Northwind adn see the functionality with that DB and then you have somthing to look at that works.

    Thursday, March 22, 2012 11:39 AM
  • User1184604244 posted

    yes i tested the setup on a simliar database with no issue so now the next thing is to know what I could have changed to alter the behavior of the foreignKey_Edit.aspx. Like i said it works on insert pages but just not the edit page and it's only the foreignKey reference that is jacked up. We did create a theme at one point where it was out of my hands and with another developer. He made some changes to the site trying to get this functionality working so I'm guessing he jacked something up, but I can't imagine what it could be.

    I'd start the site over again, but we've done so much customization to it already to go back now unfortunatly. Any ideas would be helpful. I can link some code if need be just let me know what you need to see.

    Thursday, March 22, 2012 3:50 PM
  • User-330204900 posted

    do a diff on the curretn field template and a vanilla version to see what has changed, or send me the full field template contact via direct message from my profile.

    Friday, March 23, 2012 4:52 AM
  • User1184604244 posted

    Well remember when I said i used a "similar" database and this foreignKey_edit.aspx worked fine...? Well I just rebuilt the entire site using the original database without editing anything at all in the code (except for what is required IE the global.asax to register the database) and the foreignKey_Edit.aspx reference still does not work. I should also note i decided to test it out in a website vs a webapplication to see if that made a difference. You are correct, no difference. ;)

    What was "similiar" about this database was that this database was a DB2 database using the IBM provider (I thought that maybe the IBM provider was jacked up and not passing the foreign key datatype properly to the system). Well it worked on their sample database provided by IBM (IBM's equvilant to the adventureWorksLT database). So it's clearly not the provider that was broken. So i decided to test it again with the actual database on a brand new site. The same thing happens again. Whenever I view the edit page the foreignKey reference is still being hit instead of the foreignKey_edit.aspx reference.

    So now i'm starting to think it's our database. These guys who are setting up our database are not that great on DB2. They don't use proper practices and I'm not really sure if there's something on the database side they're doing wrong to break the foreignKey_Edit.aspx reference.

    I don't suppose you know how to work with DB2 and could give me some insight as to what I should check on the database side? I'm not much better than any of them on DB2 and I've been bugging them to make this a SQL database but they won't because they don't want to add any additional requirements on our customers to switch to DB2 (which is what we've been using since the beginning of time apparently...ugh).

    Friday, March 23, 2012 9:37 AM
  • User-330204900 posted

    can you post the schema of the FK table, I am assuming DB2 creates relationships that same way as SQL Server does in the DB, they are not just inferred?

    Friday, March 23, 2012 9:44 AM
  • User1184604244 posted

    The database admins are the only ones who have access to that. I'm not sure they'll let me post it to a public forum either. What things should I be looking for? Remember i'm not much of a DB admin lol.

    Friday, March 23, 2012 9:56 AM
  • User1184604244 posted

    Ok so i'm looking in the schemas folder and I'm seeing that there's the Name and authorization columns here. (I'm using DB2Copy). The schema of the ones we're using is the only one that doesn't have SYSIBM as the authorization...the one we're using is one of our users (says P.Dumlao) and then there's a P.Dumlao schema that has SYSIBM as the authorization...not sure if that helps much...

    I'm not exactly sure what you want posted.

    Friday, March 23, 2012 10:25 AM
  • User-330204900 posted

    Hi GokuZWAR, I have3 no knowledge if DB" sorry but I do believe the Schema is where you issue lies sorry I can't help more than that. and sorry for the delay in getting back to you I have been rebuilding my PC

    Monday, March 26, 2012 8:11 AM