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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:59:36+00:00 2026-05-18T10:59:36+00:00

I have a class with all different kinds of data members, including a list

  • 0

I have a class with all different kinds of data members, including a list of strings. When I bind the data to a GridView, I want to be able to separate out the list of strings into different columns in the GridView. These strings are more like flags, there is a max of 3 flags. The list could be empty, if no flags apply, or it could contain only one or two flags. How can I separate out these flags into different GridView columns? Do I need to do it in the OnRowDataBound event?

Current, my aspx code looks something like this. I want to be able to change the ImageUrl of the Image controls based on if the flag is raised or not.

<asp:TemplateField HeaderText="Tax" SortExpression="Tax">
    <ItemTemplate>
        <asp:Image ID="imgTax" runat="server" />
    </ItemTemplate>
</asp:TemplateField>

    <asp:TemplateField HeaderText="Compliance" SortExpression="Compliance">
    <ItemTemplate>
        <asp:Image ID="imgCompliance" runat="server" />
    </ItemTemplate>
</asp:TemplateField>

    <asp:TemplateField HeaderText="Accounting" SortExpression="Accounting">
    <ItemTemplate>
        <asp:Image ID="imgAccounting" runat="server" />
    </ItemTemplate>
</asp:TemplateField>

Thanks!

  • 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-18T10:59:37+00:00Added an answer on May 18, 2026 at 10:59 am

    Is there any way for you to modify your data to turn these strings into booleans? Using strings in this way strikes me as a code smell. Personally, I would turn these strings into boolean properties of the class you’re using as the data source for your grid and modify their visibility properties in the markup, rather than go back to the database to select these properties on a row-by-row basis.

    Regardless of that, yes, you can use the RowDataBound event like this:

    yourGrid_RowDataBound(object sender, EventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            YourClass currentClass = (YourClass) e.Row.DataItem;
    
            for (int i = 0; i < currentClass.stringFlags.Length; i++)
            {
                string currentFlag = currentClass.stringFlags[i];
    
                if (currentFlag == "Tax")
                {
                    Image imgTax = (Image) e.Row.FindControl("imgTax");
                    imgTax.Visbile = true;
                }
                else if (currentFlag == "Compliance")
                {
                    Image imgCompliance = (Image) e.Row.FindControl("imgCompliance");
                    imgCompliance.Visbile = true;
                }
                else if (currentFlag == "Accounting")
                {
                    Image imgAccounting = (Image) e.Row.FindControl("imgAccounting");
                    imgAccounting.Visbile = true;
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Test Class, that test the access of all page with different
I have a base class for all my textboxes and I want to set
I have a database where I store two different kinds of data. One table
Say I have some data which I want several kinds of. I think the
I have a window contains different kinds of controls. class FindReplaceWindow(wx.MiniFrame): def __init__(self, parent):
Suppose we have abstract class A (all examples in C#) public abstract class A
If I have child class,the child class inherits all methods from the parent,but how
I have a class, Pawn, which is the base class for all characters in
I have a class which models all categories and they can be ordered hierarchically.
I have a java class containing all the columns of a database table as

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.