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

  • SEARCH
  • Home
  • 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 6832501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:51:58+00:00 2026-05-26T22:51:58+00:00

I wrote a grid helper (GridHelper.cs), it works right for all models. This Helper

  • 0

I wrote a grid helper (GridHelper.cs), it works right for all models.

This Helper has a method for rendering each row as below :

private void RenderRow(HtmlTextWriter writer, T item)
{
   writer.RenderBeginTag(HtmlTextWriterTag.Tr);          

   foreach (var col in _columns)
   {
     writer.RenderBeginTag(HtmlTextWriterTag.Td);
     var value = typeof(T).GetProperty(col.FieldName).GetValue(item, null) ?? String.Empty;                
     writer.Write(value.ToString());
     writer.RenderEndTag();
   }

   writer.RenderEndTag();
}

Also I have some DisplayTemplates in Folder: /Views/Shared/DisplayTemplates
Such as Boolean, Date, etc.

How can I change line writer.Write(value.ToString()); to using that templates?
or what changes is needed for this line to enable the use of display templates in my grid cells?

  • 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-05-26T22:51:59+00:00Added an answer on May 26, 2026 at 10:51 pm

    Use this sample for that problem

    public class TestCol<T>
        {        
            public MvcHtmlString RenderObj<T, TValue>(HtmlHelper<T> html, Expression<Func<T, TValue>> expression)
            {
                return html.DisplayFor(expression);
            }
        }
    
    
        public static class testHelper
        {
    
            //Expression<Func<TModel, TValue>> expression
            public static MvcHtmlString TestStringHelper<TModel, TValue>(this HtmlHelper<TModel> html, TValue item)
            {
                var y = new TestCol<TModel>();
                var x = y.RenderObj(html, modelitem => item);
                return x;
            }
    
            public static MvcHtmlString TestModelHelper<T>(this HtmlHelper<T> html, T item)
            {
                var list = typeof(T).GetProperties().Where(p => p.PropertyType.Namespace == "System");
                string str = "<table border=1><tr>";
                foreach (var p in list)
                {
                    var o = p.GetValue(item, null);
                    var xr = html.TestStringHelper(o).ToString();
                    if (string.IsNullOrWhiteSpace(xr)) xr = o.ToString();
                    str += string.Format("<td>{0}</td>", xr);
                }
                str += "</tr></table>";
    
                return new MvcHtmlString(str);
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Issue is that I have wrote a method to duplicate selected row in a
To implement depth-first search in a grid, I wrote a function like this (define
I wrote this script: $.getJSON('<%=Url.Action("JsonSave","Controler")%>', { id: newRow.Id, personId: newRow.PesronId}, function(data) { $('#grid').trigger('reloadGrid'); //{0}
Wrote a quick Java proggy to spawn 10 threads with each priority and calculate
I wrote a component that displays a filename, a thumbnail and has a button
I wrote this function that I want to use in a program, but for
I wrote a simple UpDown UserControl for my application. I am rendering it in
I am trying to bind a dictionary's key to a row of the grid
Im new on Dxpreince 10.(and don't think im expert on this) I wrote simple
I'm using ExtJs 3.2.2. I wrote a custom context menu to handle a grid's

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.