locked
cshtml webgrid not displaying Live Data RRS feed

  • Question

  • User927770920 posted

    Hello,

    Apolgies if this seems like a silly question.

    I have a grid within a cshtml file which is displaying data from a SQL Express Database (running on the local machine).

    If (in Webmatrix) I navigate to the Database view and run a SELECT * FROM 'table' query, all data is up-to-date.

    However, my webgrid, which is calling data from the same table is not refreshing the data.

    I am assuming this is some sort of caching issue with IIS Express but cannot seem to find a solution.

    Any help would be greatly appreciated.

    Many thanks

    Mark

    Wednesday, June 4, 2014 3:50 AM

Answers

  • User-821857111 posted

    I am assuming this is some sort of caching issue with IIS Express

    Unlikely. IIS Express doesn't implement caching. Your browser might, though. Things to check:

    • Hit Ctrl + F5 to properly refresh the browser
    • Double check that both the grid and the database view are pointing to the same table/database
    • Check to ensure that paging isn't enabled on the grid (it is by default) and that what you are seeing isn't just the first 10 rows (which will always be the same)
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 4, 2014 4:16 AM
  • User-821857111 posted

    That sounds like a WebMatrix bug. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 4, 2014 6:46 AM

All replies

  • User-821857111 posted

    I am assuming this is some sort of caching issue with IIS Express

    Unlikely. IIS Express doesn't implement caching. Your browser might, though. Things to check:

    • Hit Ctrl + F5 to properly refresh the browser
    • Double check that both the grid and the database view are pointing to the same table/database
    • Check to ensure that paging isn't enabled on the grid (it is by default) and that what you are seeing isn't just the first 10 rows (which will always be the same)
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 4, 2014 4:16 AM
  • User1713851783 posted

    To detect if is a caching issue try to use Ctrl+F5 in Internet Explorer to force the reload of the page and all its component parts.

    Aniway, if is a caching issue, it's not a WebMatrix problem: try to disable the browser cache.

    Wednesday, June 4, 2014 4:22 AM
  • User927770920 posted

    Hi,

    Many thanks for your response.

    All suggestions have been tried without luck unfortunately.

    I have now noticed that if I attempt to view the data of the table via Webmatrix (right-click > data) as opposed to using the Query, I am receiving the following error:

    "The given key was not present in the dictionary".

    This is only happening for this particular table, all others are fine.

    Does this mean anything to you as it is a new error message for me.

    Many thanks again

    Mark 

    Wednesday, June 4, 2014 4:58 AM
  • User1713851783 posted

    Maybe you should post your code.

    Wednesday, June 4, 2014 5:14 AM
  • User927770920 posted
    @{
        var db = Database.Open("progressTracker");
        var selectedData = db.Query("SELECT make,model,bodyType,customer,branchReq,orderNum,kerridgeRef,regNumber,chassisNumber,color,radioCode,keyNumber,ancilEquip,vgc,deliveryBranch,dateReqByBranch,delivDateToBranch,dealer,dealerOrdNum FROM vehicle");
        var grid = new WebGrid(selectedData,canPage:false);
    }
     
    <!DOCTYPE html>
    <html lang="en">
     
     
        <head>
            <meta charset="utf-8" />
            <title>Leeds Progress Tracker</title>
            <link rel="stylesheet" type="text/css" href="/output.css"/>
            <link rel="shortcut icon" href="/images/burnt-tree.ico">
        </head>
        <body>
     
            
            <h2>Leeds Progress Tracker</h2>
            <div id="unallocated"><a href="javascript:window.open('unallocated.cshtml','mywindowtitle','width=1024px,height=400px')">Unallocated Vehicles</a></div>
            <div id="output">
                @grid.GetHtml(
                    tableStyle: "grid",
                    headerStyle: "head",
                    alternatingRowStyle: "alt",
                    rowStyle: "row_style",
                    columns: grid.Columns(
                        grid.Column("make", "Make", style: "make"),
                        grid.Column("model", "Model", style: "model"),
                        grid.Column("bodyType", "Body Type", style: "bodyType"),
                        grid.Column("customer", "Customer", style: "customer"),
                        grid.Column("branchReq", "Branch Requirement", style: "branchReq"),
                        grid.Column("orderNum", "Order Number", style: "orderNum"),
                        grid.Column("kerridgeRef", "Kerridge Ref", style: "kerridgeRef"),
                        grid.Column("regNumber", "Reg Number", style: "regNumber"),
                        grid.Column("chassisNumber", "Chassis Number", style: "chassisNumber"),
                        grid.Column("color", "Colour", style: "color"),
                        grid.Column("radioCode", "Radio Code", style: "radioCode"),
                        grid.Column("keyNumber", "Key Number", style: "keyNumber"),
                        grid.Column("ancilEquip", "Ancilliary Equipment", style: "ancilEquip"),
                        grid.Column("vgc", "VGC", style: "vgc"),
                        grid.Column("deliveryBranch", "Delivery Branch", style: "deliveryBranch"),
                        grid.Column("dateReqByBranch", "Date Required by Branch", @<text>@item.dateReqByBranch.ToString("dd-MM-yyyy")</text>),
                        grid.Column("delivDateToBranch", "Date Delivered to Branch", @<text>@item.dateReqByBranch.ToString("dd-MM-yyyy")</text>),
                        grid.Column("dealer", "Dealer", style: "dealer"),
                        grid.Column("dealerOrdNum", "Dealer Order Number", style: "dealerOrdNum")
                        )
           )
            </div>
     
        </body>
    </html>
    Wednesday, June 4, 2014 5:16 AM
  • User-821857111 posted

    That sounds like a WebMatrix bug. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 4, 2014 6:46 AM
  • User379720387 posted

    Have you looked at selectedData from Visual Studio?

    Code running single step then hover over selectedData.

    Wednesday, June 4, 2014 7:27 AM
  • User-1454326058 posted

    Hi markweaton,

    First, I suggest that you should debug it in the VS if the VS has been installed. (Click Visual Studio button in the WebMatrix) If you don’t have VS install. Please check the selectedData count or print the first record data.

    <div>
    @selectedData.Count()
    </div>
    

    Secondly, for the error of “The given key was not present in the dictionary”, I can reproduce that scene. I checked the reason. I find the reason is that there are the specify datatype that the webmatrix doesn’t support, such as geography.

    On the other hand, please create a new project and try again.

    Thanks

    Best Regards

    Wednesday, June 4, 2014 11:40 PM