Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8491871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:33:25+00:00 2026-06-10T22:33:25+00:00

I am working with the helper Html.WebGrid in MVC3, how I can do to

  • 0

I am working with the helper Html.WebGrid in MVC3, how I can do to include the data for each TR tag?.

I have data in a column, I do not want to show the column, and I need these data are on the TR of the table, and then work with JavaScript.

Thank you.

EDIT

public class MyModel
{

public DataTable Data { get; set; }

public IList<dynamic> Results()
{
    var columnas = this.Columnas();
    var result = new List<dynamic>();
    foreach (DataRow row in this.Data.Rows)
    {
        var obj = (IDictionary<string, object>)new ExpandoObject();
        foreach (DataColumn column in columns)
        {
            if (!columna.ColumnName.StartsWith("_"))
            {
                obj.Add(column.ColumnName, row[column.ColumnName]);
            }
        }
        result.Add(obj);
    }

    return result;
}

private IList<DataColumn> Columns()
{
    var columns = new List<DataColumn>();
    foreach (DataColumn column in this.Data.Columns)
    {
        columns.Add(column);
    }

    return columns;
}
}

page.schtml

@model MySite.Model.MyModel

@using System.Data

@{
    ViewBag.Title = "My page";
    Layout = "~/Views/Shared/Layout.cshtml";
}
<h2>Resultados</h2>
@{
    if (Model == null) { 
        <div>
            <div>no results</div>
        </div>
    }
    else {
        <div>
            <div>Rows:  <span>@Model.Data.Rows.Count</span></div>
            @{

        var grid = new WebGrid(source: Model.Results(), rowsPerPage: 10);

        @grid.GetHtml(
                fillEmptyRows: true,
                alternatingRowStyle: "fila-alternativa",
                headerStyle: "encabezado-grid",
                footerStyle: "pie-grid",
                mode: WebGridPagerModes.All,
                firstText: "<< Primera",
                previousText: "< Anterior",
                nextText: "Siguiente >",
                lastText: "Última >>"
            )
        }

        @Html.HiddenFor(model => Model.Filtros.TipoConsultaSiguiente)
    </div>
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T22:33:27+00:00Added an answer on June 10, 2026 at 10:33 pm

    You can set up a class for this column when configure your grid

    @MvcHtmlString.Create(grid.GetHtml(htmlAttributes: new { id = "grid" },
                                             tableStyle: "members_table",
                                             rowStyle: "alt",
                                             mode: WebGridPagerModes.All,
                                             columns: grid.Columns(
                                                   grid.Column(columnName: "Id", format: @<text>@item.id</text>, style: "hiddenColumn"), ...
    

    and in hiddenColumn class set up visibility for this column.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone have a working sample of json paging for mvc3 webgrid? I've been
I have am working on a web application that makes use of helper classes.
Recently I posted a question about the html helper dropdownlist and got it working
I have the following WebGrid in my ASP.NET MVC3 test application. It displays a
I have some code (that is working), but I just want to make sure
I have a custom Action Helper that is working fine. It's generating a dynamic
I have a html helper thanks to Darin however I have done something to
I am working on a helper macro that look into the list function on
Im writing some helper functions for a project im working on. I've always wanted
I spent the last three days working on the collection _ select form helper

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.