Dynamic Data Make Table Read-Only

Posted on 2009-04-22
Last Modified: 2012-05-06
What is the easiest way to make a table Read-Only in a Dynamic Data web application WITHOUT having to make a custom page for each table?  Can you do this in the routing...or using partial classes???  VB.NET code only please :)
Question by:natek11
    LVL 96

    Expert Comment

    by:Bob Learned
    Hmmm...that is a pretty vague question, since you might be talking about an HTML table, a DataTable, a database table, ...

    Author Comment

    A Dynamic Data site automatically builds classes and web pages to view/add/edit/delete from database tables.  So basically I need to set the configuration in the site to make the automatically generated page for certain database tables not contain add/edit/delete functionality.

    I think I can maybe do it with routing...but I'm still trying to figure it out.
    LVL 96

    Expert Comment

    by:Bob Learned
    Great, you are talking about something that I haven't gotten to yet, since I don't have access to ASP.NET 3.5...

    Accepted Solution

    You should definitely check out 3.5 - LINQ and Dynamic Data are both really handy.

    I ended up solving this by creating a custom version of the ListDetails.aspx page and using custom routing in the Global.asax.vb file to look at a hard coded ArrayList of table names.  Probably not the best way, but it worked.
    For Each s As String In Functions.GetROTableNames
                routes.Add(New DynamicDataRoute(s & "/ListDetailsRead.aspx") With { _
                    .Action = PageAction.List, _
                    .ViewName = "ListDetailsRead", _
                    .Model = model, _
                    .Table = s})
            Next s
            routes.Add(New DynamicDataRoute("{table}/ListDetails.aspx") With { _
                .Action = PageAction.List, _
                .ViewName = "ListDetails", _
                .Model = model})
            routes.Add(New DynamicDataRoute("{table}/ListDetails.aspx") With { _
                .Action = PageAction.Details, _
                .ViewName = "ListDetails", _
                .Model = model})

    Open in new window


    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now