locked
UIHint does not work for Foreign keys RRS feed

  • Question

  • User1432255915 posted

    Hi,

    How do I remove the "link" that is created by default in the GridView for foreing keys and many to many relations? I still want to display the text but without the navigation link.

    I have tried using a UIHint attribute to change the foreign key to use the Text.ascx control but then it displays the toString() text "BBLDSAccessManager.DAL.Department" for all rows.

    Please can someone shed some light?

     

    public class PositionMetaData
    {
            [UIHint("Text")]
            public object Department;
    }

    Cheers,

    CP

    Wednesday, October 3, 2012 7:53 AM

Answers

  • User-330204900 posted

    in the field template there is a AllowNavigation property I generally add some code there and you can pass in a value usign the UIHint's control attributes and use this code to retrieve the value;

    [FilterUIHint("DefaultValueBoolean", null, "Value", true)]
    

    Then you can get the value like so;

    protected void Page_Init(object sender, EventArgs e)
    {
      var uIHint = Column.GetAttribute<UIHintAttribute>();
      if (uIHint != null && uIHint.ControlParameters.ContainsKey("Value"))
        AllowNavigation = (Boolean)uIHint.ControlParameters["Value"];

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 3, 2012 10:11 AM
  • User-330204900 posted

    Then FilterUIHintAttribute is a part of .Net 4 onwards.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 4, 2012 7:10 PM

All replies

  • User-330204900 posted

    in the field template there is a AllowNavigation property I generally add some code there and you can pass in a value usign the UIHint's control attributes and use this code to retrieve the value;

    [FilterUIHint("DefaultValueBoolean", null, "Value", true)]
    

    Then you can get the value like so;

    protected void Page_Init(object sender, EventArgs e)
    {
      var uIHint = Column.GetAttribute<UIHintAttribute>();
      if (uIHint != null && uIHint.ControlParameters.ContainsKey("Value"))
        AllowNavigation = (Boolean)uIHint.ControlParameters["Value"];

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 3, 2012 10:11 AM
  • User1432255915 posted

    Hi Steve,

    Thanks again for this reply.

    Could you please provide the code for the FilterUIHint?

    Cheers

    CP

    Wednesday, October 3, 2012 11:59 AM
  • User-330204900 posted

    Are you using pre .Net 4?

    Thursday, October 4, 2012 4:58 AM
  • User1432255915 posted

    Hi Steve,

    Yes, I am. Thanks.

    Thursday, October 4, 2012 2:27 PM
  • User-330204900 posted

    Then FilterUIHintAttribute is a part of .Net 4 onwards.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 4, 2012 7:10 PM
  • User3866881 posted

    Could you please provide the code for the FilterUIHint?

    Hello,

    The example looks something like this:(See msdn at:http://msdn.microsoft.com/en-us/library/system.web.dynamicdata.dynamicfilter.filteruihint.aspx)

    <asp:DynamicFilter ID="CategoryFilter" runat="server" 
        FilterUIHint="ForeignKey" />
    Thursday, October 4, 2012 9:30 PM
  • User-330204900 posted

    Hi Decker, I think he means the source for FilterUIHint not the how to use...

    [FilterUIHint("DefaultValueBoolean", null, "Value", true)] 

    I provided the how to in the sample above.

    Friday, October 5, 2012 7:42 AM
  • User1432255915 posted

    Hi Steve, Decker,

    You are right. I was wondering if I had to create another control and call it "DefaultValueBoolean.ascx"

    Am I right to think that I have to copy the Boolena.ascx control and call it DefaultValueBoolean and then add your code above?

    Cheers,

    CP

     

     

    Friday, October 5, 2012 9:56 AM
  • User-330204900 posted

    Hi Pallone, yes you do need to create your own custom filter user control and add the extra code there :)

    Friday, October 5, 2012 10:14 AM
  • User1432255915 posted

    Hi Steve,

    thanks a lot for  your help. I will try that.

    By the way, I have just sent an email to you directly. Could you please let me know what you think?

    Cheers

    C

    Friday, October 5, 2012 10:21 AM