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 8313027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:21:31+00:00 2026-06-08T20:21:31+00:00

How can I create a template in c# for an AXPxGridViewDataTextColumn without any markup

  • 0

How can I create a template in c# for an AXPxGridViewDataTextColumn without any markup and with using Eval to display the DataItem value?

-The problem that I am having is that the string “<%#Eval(“dataTableField1″)%>” shows up in the GridView for every row instead of the appropriate values.

Here is an example of my attempt:

    public override void DataBind()
    {
        ...
        GridViewDataTextColumn myCol = new GridViewDataTextColumn();
        myCol.Caption = "col1";
        myCol.FieldName = "dataTableField1";
        myCol.DataItemTemplate = new ColumnDataItemTemplate();
        theGridView.Columns.Clear();
        theGridView.Columns.Add(myCol);
        theGridView.DataSource = AdjustDataSource();
        theGridView.DataBind();
        ...
    }

    public class ColumnDataItemTemplate : ITemplate
    {
        public void InstantiateIn(Control container)
        {
            GridViewDataItemTemplateContainer Container = (container as GridViewDataItemTemplateContainer);
            LiteralControl lit = new LiteralControl("<div id=\"hr\" style=\"height:100%\"><%#Eval(\"dataTableField1\")%></div>");
            Container.Controls.Add(lit);
        }
    }

Here is an example of what I want to do with the row height taken from this link:

<dx:GridViewDataTextColumn FieldName="Description" VisibleIndex="3">
    <DataItemTemplate>
        <div id="hr" style="height:100%">
            <%#Eval("Description")%>
        </div>
    </DataItemTemplate>
</dx:GridViewDataTextColumn>

This documentation link shows similar examples of using templates in the markup but I want to do it in the code behind.

Here is a link on creating templates.

Thanks in advance,

Soenhay

Edit:
I was able to get the first element to properly display by moving the template assignment to the CustomColumnDisplayText event but all other elements displayed in the ASPxGridView show the Eval string.

  • 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-08T20:21:33+00:00Added an answer on June 8, 2026 at 8:21 pm

    I had 2 other solutions but I removed them as I think this is the best ( I would be grateful for any other suggestions/improvements ):

            public override void DataBind()
            {
                 ...
                 GridViewDataTextColumn myCol = new GridViewDataTextColumn();
                 myCol.Caption = "col1";
                 myCol.FieldName = "dataTableField1";
                 myCol.DataItemTemplate = new ColumnDataItemTemplate();
                 theGridView.Columns.Clear();
                 theGridView.Columns.Add(myCol);
                 theGridView.DataSource = AdjustDataSource();
                 theGridView.DataBind();
                 ...
            }
    
            public class ColumnDataItemTemplate : ITemplate
            {
                public void InstantiateIn(Control container)
                {
                    GridViewDataItemTemplateContainer Container = (container as GridViewDataItemTemplateContainer);
                    LiteralControl lit = new LiteralControl("<div id='hr' style='height:100%; font-size:x-large;'>" + DataBinder.Eval(Container.DataItem, Container.Column.FieldName) + "</div>");
                    Container.Controls.Add(lit);
                }
            }
    

    At this link I have found a reason to not use the event:
    “The CustomColumnDisplayText event should not be handled for template columns. “

    This link helped with the DataBinder.Eval part.

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

Sidebar

Related Questions

I am aware that one can create template filters in Django templates such as
I know that I can create xml files programmatically by using DOM api in
I'm using this pretty handy JavaScript template library: https://github.com/blueimp/JavaScript-Templates . I can create elements
I need to create a Word template where I can choose from different paragraphs
I can create a contact that is not mail enabled, but how do I
One can create an anonymous object that is initialized through constructor parameters, such as
How I can create custom file template in VS2010? I mean when I add
I have written an application that uses the Tinymce editor. The administrator can create
How can create multilingual Django site? Is it a good idea to create template
I can create forms via templates with no problem. I found a plugin (create-page)

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.