473,407 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Dynamically create TemplateColumn

Hi there, I cannot write a datagrid on the aspx because i do not know the
names of the column headings until i run a query. So i have to do it
programatically from the datasource.

I have managed to add a couple of boundcolumns based on my datasource easy
peasy but can't find any help anywhere to show me how to dynamically set up
the itemtemplate within a templatecolumn (and add say a checkbox to it). So
what goes after this? I know the syntax is wrong in the following but I cant
find anything close to this in the properties or methods of templatecolumn.
I read another post saying 'new columnTemplate' but cant find this class
anywhere..

TemplateColumn tc = new TemplateColumn();
//want to do the following
ItemTemplate it = new ItemTemplate()
it.Controls.Add(a Checkbox)
tc.Controls.Add(it)
Nov 19 '05 #1
2 4119
Hi,

Implementing Dynamic ItemTemplates
http://scottwater.com/articles/DynamicItemTemplates

-
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

"louise raisbeck" <lo************@discussions.microsoft.com> wrote in
message news:C4**********************************@microsof t.com...
Hi there, I cannot write a datagrid on the aspx because i do not know the
names of the column headings until i run a query. So i have to do it
programatically from the datasource.

I have managed to add a couple of boundcolumns based on my datasource easy
peasy but can't find any help anywhere to show me how to dynamically set up the itemtemplate within a templatecolumn (and add say a checkbox to it). So what goes after this? I know the syntax is wrong in the following but I cant find anything close to this in the properties or methods of templatecolumn. I read another post saying 'new columnTemplate' but cant find this class
anywhere..

TemplateColumn tc = new TemplateColumn();
//want to do the following
ItemTemplate it = new ItemTemplate()
it.Controls.Add(a Checkbox)
tc.Controls.Add(it)

Nov 19 '05 #2
Thanks for that. very helpful. however i havent worked out from that how to
add controls such as a checkbox to the itemtemplate. Theres no control
collection or add method anywhere ??

"Teemu Keiski" wrote:
Hi,

Implementing Dynamic ItemTemplates
http://scottwater.com/articles/DynamicItemTemplates

-
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

"louise raisbeck" <lo************@discussions.microsoft.com> wrote in
message news:C4**********************************@microsof t.com...
Hi there, I cannot write a datagrid on the aspx because i do not know the
names of the column headings until i run a query. So i have to do it
programatically from the datasource.

I have managed to add a couple of boundcolumns based on my datasource easy
peasy but can't find any help anywhere to show me how to dynamically set

up
the itemtemplate within a templatecolumn (and add say a checkbox to it).

So
what goes after this? I know the syntax is wrong in the following but I

cant
find anything close to this in the properties or methods of

templatecolumn.
I read another post saying 'new columnTemplate' but cant find this class
anywhere..

TemplateColumn tc = new TemplateColumn();
//want to do the following
ItemTemplate it = new ItemTemplate()
it.Controls.Add(a Checkbox)
tc.Controls.Add(it)


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Webgour | last post by:
Hi, I'm tring to add a column to a datagrid with a linkbutton as header that can be used to sort the column. The column and the linkbutton are added programmatically (see below). However the...
0
by: sameer mowade via .NET 247 | last post by:
Hello All, I have problem while dynamically removing row from the Datagrid which i have added dynamically as shown in the following code snippet. The problem is that while removing dynamically...
4
by: Sileesh | last post by:
Hi I have datagrid with 8 items. Out of which 2 items are checkboxes. Data is binded dynamically to the datagrid Based on some values from the database I have to check or uncheck the checkbox...
0
by: news.zen.co.uk | last post by:
Hi Guys, Using VB .NET 2003 and ASP1.1, I have a Datagrid embedded in an ASP page. In the processing of the ItemDataBound event I dynamically create a new Datagrid control within the Cell of the...
4
by: sydney.luu | last post by:
Hello, I would greatly appreciate if someone can show me how to dynamically build a Repeater with unknown number of columns at design time. I have looked various threads in this newsgroup,...
2
by: Pete Moss | last post by:
During a postback event, I am having trouble retrieving the state of a CheckBox Control that I am dynamically adding to a DataGrid Control using ASP.NET 1.1. I have no trouble adding the...
0
by: Silver Oak | last post by:
I have a DataGrid in which one of the columns is TemplateColumn that was created dynamically using iTemplate. I would like to have multi-row editing capability on the DataGrid. I'm trying to...
5
by: tshad | last post by:
I found I can create Template columns dynamically - as long as I don't use objects that need onclick events, such as a LinkButton. Textboxes and Labels work fine. I create the Template columns...
10
by: gnewsgroup | last post by:
I've googled and tried various approaches, but could not resolve this problem. The article at MSDN: Displaying Images in a GridView Column only presents a simple case where all data (including the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.