Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Dynamically adding webpart properties

Dynamically adding webpart properties

Scheduled Pinned Locked Moved ASP.NET
questiondatabasesalesannouncementlounge
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    robert110
    wrote on last edited by
    #1

    I have a webpart that displays departmental news. Every department have different news section for instance Admin dept have three news section: 1- Admin 2- HR 3- General Sales dept have four: 1- Company Sales News 2- Stock News 3- Global Market News 4- Sales Forecast Now, I want to expose these sections as properties of my WebPart so if a Sales user is logged in; when he will enter Edit Mode; he sees all four sections in Sales Dept and from which he can choose what all it is that he wants to see on the webpart. I can hardcode something like this:

      protected bool _CompanySales = true;
      [ Personalizable(PersonalizationScope.User), 
        WebBrowsable,
        WebDisplayName("Company's Sales News"), 
        WebDescription("Use this property to show/hide Company's Sales news")]
      public bool CompanySales  {
        get { return _CompanySales ; }
        set { _CompanySales = value; }
      }
    
      protected bool _StockNews= true;
      [ Personalizable(PersonalizationScope.User), 
        WebBrowsable,
        WebDisplayName("Stock News"), 
        WebDescription("Use this property to show/hide Stock News")]
      public bool StockNews{
        get { return _StockNews; }
        set { _StockNews= value; }
      }
    
      protected bool _GlobalMarketNews= true;
      [ Personalizable(PersonalizationScope.User), 
        WebBrowsable,
        WebDisplayName("Global Market News"), 
        WebDescription("Use this property to show/hide Global Market News")]
      public bool GlobalMarketNews{
        get { return _GlobalMarketNews; }
        set { _GlobalMarketNews= value; }
      }
    // ...
    // ETC
    

    But I wouldn't have any knowldge of these sections because they are stored in the database. So I guess my question is; how can I dynamically define properties of a webpart by pulling the data from a datasource? Thanks in advance.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups