locked
MVC _Layout page RRS feed

  • Question

  • Hi

    I am tying to load in a string to display on my menus.  The string is in my database and it is to show which company it is.  Any clues would be very welcome. 

    <li class="sidebar-brand">

    <a href="#" id="tyres">         @Html.???     </a>

    </li>

            

    • Moved by CoolDadTx Friday, June 30, 2017 4:59 PM ASP.NET related
    Friday, June 30, 2017 4:05 PM

All replies

  • MVC solutions are discussed at MVC section forum.

    http://forums.asp.net/

    Friday, June 30, 2017 4:14 PM
  • Actually what you need to do is, you need to fetch the record from database. That you have not shared, so, I will consider that you will rewrite this. Anyways, instead of using the Html helpers you need to use a variable or a model that will render the results captured from the database. 

    @model YourTypeHere
    
    @{
        // Any initialization
    }
    
    <a href="#" id="tyres">
       @Model.Title
    </a>
    

    Anyways, you would have to load the data from the Controller, the data access should move back to the Controller and you should load the data from there. I wrote an article covering the SQL Server connectivity in C#, you can read that article here, https://www.codeproject.com/Articles/823854/How-to-connect-SQL-Database-to-your-Csharp-program. You can apply the same concepts in ASP.NET and read the data from database. 

    Finally, ASP.NET forums are separately available and topics discussing the ASP.NET related questions should be asked there, https://forums.asp.net/. 


    The sh*t I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem

    Friday, June 30, 2017 4:41 PM
  • Thanks, that helps.

    J

    Monday, July 3, 2017 10:28 AM