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