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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:32:51+00:00 2026-05-12T11:32:51+00:00

Here are a few properties of my class. There is also a public object

  • 0

Here are a few properties of my class. There is also a public object of another class DNRole

    private Int32 _IDMarketingCampaign;
    private String _Name;

    public Int32 IDMarketingCampaign
    {
        get { return _IDMarketingCampaign; }
        set { _IDMarketingCampaign = value; }
    }
    public String Name
    {
        get { return _Name; }
        set { _Name = value; }
    }
    public DPRole DNRole = new DPRole();

In the same class I have a method returnig List. Besides my regular fields, I’m also populating one field of my DNRole object:

listItem.DNRole.RoleName = dr[“RoleNameFK”].ToString();

My question is.. Is this legal and is it how it should be done, and if yes, how do I show data in a girdview?

public List<MarketingCampaign> SelectForGrid(string strRoleName)
        {
            List<MarketingCampaign> lista = new List<MarketingCampaign>();
            SqlCommand command = new SqlCommand("fra_MarketingCampaignSelectForGrid ", conn);
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("RoleName", SqlDbType.VarChar).Value = strRoleName;
            SqlDataReader dr = null;
            try
            {
                conn.Open();
                dr = command.ExecuteReader();
                while (dr.Read())
                {
                    MarketingCampaign listItem = new MarketingCampaign();

                    listItem.IDMarketingCampaign = Convert.ToInt32(dr["IDMarketingCampaign"]);
                    listItem.Name = dr["Name"].ToString();
                    listItem.DNRole.RoleName = dr["RoleNameFK"].ToString();
                    ...
                    lista.Add(listItem);
                }
  • 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-12T11:32:51+00:00Added an answer on May 12, 2026 at 11:32 am

    You can use ObjectDataSource – to wrap call SelectForGrid, also you can direct bind List to your GridView:

    MyGrid.DataSoure = some. SelectForGrid();
    MyGrid.DataBind();
    

    When data is binded in *.aspx/ascx code you need bind columns to properties:
    Eval and Bind allows you do it by name, but faster way to use explicit cast to MarketingCampaign.

    <asp:TemplateField >
         <ItemTemplate> 
            <%#((MarketingCampaign)Container.DataItem).Name%> 
         </ItemTemplate>
    

    …

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

Sidebar

Related Questions

Here are a few example of classes and properties sharing the same identifier: public
There are a few pages here addressing usage of jQuery with .net masterpages -
Having used optional parameters in a few classes here and there, I'm starting to
Okay, I browsed through a few topics here, but there was no definite answer.
I have subclassed the UICollectionViewLayoutAttributes class and added a few custom properties. In my
I have a class with a few properties that are dependent, but that I'd
I have an object which has some properties and a few of those properties
I've posted the same question here a few days ago( Java reading standard output
A few questions here, regarding letcc that is used in The Seasoned Schemer. (define
I've got a few controllers here at work that contain methods I can use

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.