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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:00:28+00:00 2026-06-11T07:00:28+00:00

I would like to make a simple adapter for the Gridview control that would

  • 0

I would like to make a simple adapter for the Gridview control that would render the cell contents inside a <div> tag.

Instead of rendering as

<table>
  <tr>
    <td>Some Data</td>
    <td>Some Data</td>
  </tr>
</table>

I would like it to render as

<table>
  <tr>
    <td><div>Some Data</div></td>
    <td><div>Some Data</div></td>
  </tr>
</table>

I understand this can be done other ways using Jquery or in RowDataBound, but I specifically would like to do it with an adapter.

I seems to me the change would be simple if there was a way to see the code for an adapter that creates the default .Net Gridview, however I do not know how to obtain that code.

Any help is greatly appreciated.

  • 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-11T07:00:30+00:00Added an answer on June 11, 2026 at 7:00 am

    Microsoft provides a reference implementation of Control adapters in form of the CSS Friendly Control Adapters

    You can take a look at how they have implemented the GridViewAdapter

    Here is the bit of the code that deals with rendering the rows

    private void WriteRows(HtmlTextWriter writer, GridView gridView, GridViewRowCollection rows, string tableSection)
    {
        if (rows.Count > 0)
        {
            writer.WriteLine();
            writer.WriteBeginTag(tableSection);
            writer.Write(HtmlTextWriter.TagRightChar);
            writer.Indent++;
    
            foreach (GridViewRow row in rows)
            {
                if (!row.Visible)
                    continue;
    
                writer.WriteLine();
                writer.WriteBeginTag("tr");
    
                string className = GetRowClass(gridView, row);
                if (!String.IsNullOrEmpty(className))
                {
                    writer.WriteAttribute("class", className);
                }
    
                writer.Write(HtmlTextWriter.TagRightChar);
                writer.Indent++;
    
                foreach (TableCell cell in row.Cells)
                {
                    DataControlFieldCell fieldCell = cell as DataControlFieldCell;
                    if ((fieldCell != null) && (fieldCell.ContainingField != null))
                    {
                        DataControlField field = fieldCell.ContainingField;
                        if (!field.Visible)
                        {
                            cell.Visible = false;
                        }
    
                        // Apply item style CSS class
                        TableItemStyle itemStyle;
                        switch (row.RowType)
                        {
                            case DataControlRowType.Header:
                                itemStyle = field.HeaderStyle;
                                // Add CSS classes for sorting
                                SetHeaderCellSortingClass(gridView, field, itemStyle);
                                break;
                            case DataControlRowType.Footer:
                                itemStyle = field.FooterStyle;
                                break;
                            default:
                                itemStyle = field.ItemStyle;
                                break;
                        }
                        if (itemStyle != null && !String.IsNullOrEmpty(itemStyle.CssClass))
                        {
                            if (!String.IsNullOrEmpty(cell.CssClass))
                                cell.CssClass += " ";
                            cell.CssClass += itemStyle.CssClass;
                        }
                    }
    
                    writer.WriteLine();
                    cell.RenderControl(writer);
                }
    
                writer.Indent--;
                writer.WriteLine();
                writer.WriteEndTag("tr");
            }
    
            writer.Indent--;
            writer.WriteLine();
            writer.WriteEndTag(tableSection);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to make a nested cell array as follows: tag = {'slot1'}
I would like to make a simple panel with buttons that are placed horizontally
I would like to make a very simple ant script that does 1 thing,
I would like to make a simple game in Java that has already been
i would like make a simple script that store one dynamic image (Random) in
I would like to make a simple web app that displays 20 or so
I would like to make a simple notice / news system for website administrators.
I have some data in .cvs. I would like to make a simple barplot
Would like to make anapplication in Java that will not automatically parse parameters used
I would like to make a function that takes in a list of integers

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.