How to get an object from the webgrid.


Instead of using @RenderPage try

    UserSearchDisplayModel user =
grid.Rows[grid.SelectedIndex].Value;
    @Html.Partial("_AdminUserDetails", user)

Works for me.



MVC 4 how to set row id for a WebGrid

You can specify the format of each column when you set the grid up:

grid.Column("InvoiceID", header: "Invoice",
                format:
@<text>@Html.ActionLink((string)item.InvoiceID.ToString(),
                "Invoice", "Invoice", new { invoiceID = item.InvoiceID
}, null)</text>),

This will generate the appropriate link with an ID to pass back to your controller.


Webgrid: Cannot convert lambda expression to type 'object' because it is not a delegate type

You can't use embedded razor strings within the lambda expression, as @Alessandro D'Andra suggests you have to use x => "<img src='" + someString + "'></img>"; instead.

You might also have to wrap it all in an MvcHtmlString to prevent Razor from escaping the string once it is used by the formatter, but I don't know exactly how the formatter works - you have to try it.

I made a small test file to find out exactly what the Razor compiler would do with your code. This is the razor file:

@{
    string someString = "somestring";

    Func<object, object> a = x => "<text><img src='"
+ someString + "'></img></text>";
    Func<object, object> b = x => @<text><img
src="@someString"></img></text>);  
}

The ASP.NET compiler creates this C# code out of it (only relevant parts included):

    string someString = "somestring";

    Func<object, object> a = x => "<text><img src='"
+ someString + "'></img></text>";
    Func<object, object> b = x => 

            #line default
            #line hidden
item => new
System.Web.WebPages.HelperResult(__razor_template_writer => {

BeginContext(__razor_template_writer, "~/Views/Home/Index.cshtml",
210, 4, true);

WriteLiteralTo(__razor_template_writer, "<img");

EndContext(__razor_template_writer, "~/Views/Home/Index.cshtml", 210,
4, true);

WriteAttributeTo(__razor_template_writer, "src", Tuple.Create("
src="", 214), Tuple.Create(""", 231)

            #line 7 "c:	empMvcApplication1ViewsHomeIndex.cshtml"
, Tuple.Create(Tuple.Create("", 220), Tuple.Create<System.Object,
System.Int32>(someString

            #line default
            #line hidden
, 220), false)
);

BeginContext(__razor_template_writer, "~/Views/Home/Index.cshtml",
232, 7, true);

WriteLiteralTo(__razor_template_writer, "></img>");

EndContext(__razor_template_writer, "~/Views/Home/Index.cshtml", 232,
7, true);

Using the embedded text syntax @<text> within the lambda expression creates obviously incorrect C# code. It is not smart enough to make the embedded tags part of the lambda expression, instead it breaks the lambda expression by inserting code to emit the embedded text right away.


ASP.NET MVC4 WebGrid how to display all pages in the WebGrid

found a partial answer to my question.

@grid.GetHtml(
    mode: WebGridPagerModes.All,
    firstText: "<< First",
    previousText: "< Prev",
    nextText: "Next >",
    lastText: "Last >>",
...

Identifying an WebTable/WebGrid Object in QTP

Ok, so assuming you have an HTML structure something like this:

<table width="90%">
  <tr>
    <td>
      <div class="greybox" style="margin-top:2%;">
        <table class="datagrid" width="100%">
          <tr>
            <td>UniqueText</td>
          </tr>
        </table>
      </div>
    </td>
  </tr>
</table>

...and as per your current solution you can rely on "UniqueText" being present, then you could try the following XPath statement:

(//table[contains(., 'UniqueText')])[last()]

So in QTP/UFT you'd be doing:

Browser("micClass:=Browser").Page("micClass:=Page").WebTable("xpath:=(//table[contains(.,
'UniqueText')])[last()]")

Show progress bar until the webgrid completely loads and pagging to next or previous pages in the webgrid in MVC

TRY THIS:::

div #spinner {
                display: none;
                width: auto;
                height: auto;
                position: fixed;          
                background: url(spinner.gif) no-repeat center #fff;
                text-align: center;
                padding: 10px;
                font: bold 16px Tahoma, Geneva, sans-serif;
                border: 1px solid #666;
                margin-left: -50px;
                margin-top: -50px;
                z-index: 2;
                overflow: auto;
            }

    function showProgress() {
                if (!spinnerVisible) {
                    $("#spinner").fadeIn("fast");
                    spinnerVisible = true;
                }
            };
            function hideProgress() {
                if (spinnerVisible) {
                    var spinner = $("#spinner");
                    spinner.stop();
                    spinner.fadeOut("fast");
                    spinnerVisible = false;
                }
            };

            $(document).ajaxStart(function () {
                showProgress();           
            }).ajaxStop(function () {
                hideProgress();
            });    

How to get an object from the webgrid.

Instead of using @RenderPage try

    UserSearchDisplayModel user =
grid.Rows[grid.SelectedIndex].Value;
    @Html.Partial("_AdminUserDetails", user)

Works for me.



- Technology - Languages
+ Webmasters
+ Development
+ Development Tools
+ Internet
+ Mobile Programming
+ Linux
+ Unix
+ Apple
+ Ubuntu
+ Mobile & Tablets
+ Databases
+ Android
+ Network & Servers
+ Operating Systems
+ Coding
+ Design Software
+ Web Development
+ Game Development
+ Access
+ Excel
+ Web Design
+ Web Hosting
+ Web Site Reviews
+ Domain Name
+ Information Security
+ Software
+ Computers
+ Electronics
+ Hardware
+ Windows
+ PHP
+ ASP/ASP.Net
+ C/C++/C#
+ VB/VB.Net
+ JAVA
+ Javascript
+ Programming
Privacy Policy - Copyrights Notice - Feedback - Report Violation 2018 © BigHow