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. Dynamic item tempalte with different control in datalist

Dynamic item tempalte with different control in datalist

Scheduled Pinned Locked Moved ASP.NET
helpdatabasewpfdesigntutorial
3 Posts 3 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.
  • S Offline
    S Offline
    Shah Ritesh
    wrote on last edited by
    #1

    Hello Friends, I am stuck with DataList. Let me explain you my problem. I have one dataset which suppose to bind with DataList (or any control which can cater my need). For example I have five column in my database EmpID (int), EmpName (string), IsAdmin(Bool), IsFullTimeEMP(Bool), IsInIT(Bool) Now I don’t know at design time how many column I want to display. I may display first three column or four or all five. First two columns suppose to be displayed in simple text format but any of last three should be displayed as a “check box”. If I add all item templates at design time, it works fine but the main problem is I don’t know how many columns I have to display, I can decide it at run time. This is somehow urgent to me. Can anyone help? Any suggestions are highly appreciated.

    C S 2 Replies Last reply
    0
    • S Shah Ritesh

      Hello Friends, I am stuck with DataList. Let me explain you my problem. I have one dataset which suppose to bind with DataList (or any control which can cater my need). For example I have five column in my database EmpID (int), EmpName (string), IsAdmin(Bool), IsFullTimeEMP(Bool), IsInIT(Bool) Now I don’t know at design time how many column I want to display. I may display first three column or four or all five. First two columns suppose to be displayed in simple text format but any of last three should be displayed as a “check box”. If I add all item templates at design time, it works fine but the main problem is I don’t know how many columns I have to display, I can decide it at run time. This is somehow urgent to me. Can anyone help? Any suggestions are highly appreciated.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      The GridView control can be made to automatically generate it's columns from the contents of the data source. AutoGenerateColumns="true" or somethign like that

      Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      1 Reply Last reply
      0
      • S Shah Ritesh

        Hello Friends, I am stuck with DataList. Let me explain you my problem. I have one dataset which suppose to bind with DataList (or any control which can cater my need). For example I have five column in my database EmpID (int), EmpName (string), IsAdmin(Bool), IsFullTimeEMP(Bool), IsInIT(Bool) Now I don’t know at design time how many column I want to display. I may display first three column or four or all five. First two columns suppose to be displayed in simple text format but any of last three should be displayed as a “check box”. If I add all item templates at design time, it works fine but the main problem is I don’t know how many columns I have to display, I can decide it at run time. This is somehow urgent to me. Can anyone help? Any suggestions are highly appreciated.

        S Offline
        S Offline
        ssurya4u
        wrote on last edited by
        #3

        Hi, Create an GridVew say it's ID (grdEmployee) with 5 columns at design time and make the last three ItemTemplates visible false. and set AutoGenerateColumns property to false only. And In Page_Load event based on ur req. display ur columns by using following syntax: if u need to display 3rd ItemTemplate use the following code snippet: grdEmployee.columns(2).Visible = true if u need to display 4th ItemTemplate use the following code snippet: grdEmployee.columns(3).Visible = true if u need to display 5th ItemTemplate use the following code snippet: grdEmployee.columns(4).Visible = true

        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