473,386 Members | 1,699 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,386 software developers and data experts.

GridView-Adding TemplateField programatically

This seems more diffciult than it should be, can someone provide any insight?
Platform is VB 2005, gridview on a web page.

I have this code in the aspx file of a GridView control:

<asp:TemplateField >
<ItemTemplate>
<asp:CheckBox ID="chkNotifierAdd" runat="server"/>
</ItemTemplate>
</asp:TemplateField>

I need to add the TemplateField, ItemTemplate, and Checkbox controls all
programatically, not hard wired in the aspx. I can instantiate a template
field object, but I cannnot instantiate a ItemTemplate object (the
ItemTemplate class doesn't exist) to subsequently add my checkbox. What is
the procedure?

Thanks - Hedge
Oct 16 '06 #1
2 27391
You need to create your own class that implements the ITemplate interface.

The following link shows an example of one.

http://msdn2.microsoft.com/en-us/lib...latefield.aspx

Steve

"Tony Hedge" wrote:
This seems more diffciult than it should be, can someone provide any insight?
Platform is VB 2005, gridview on a web page.

I have this code in the aspx file of a GridView control:

<asp:TemplateField >
<ItemTemplate>
<asp:CheckBox ID="chkNotifierAdd" runat="server"/>
</ItemTemplate>
</asp:TemplateField>

I need to add the TemplateField, ItemTemplate, and Checkbox controls all
programatically, not hard wired in the aspx. I can instantiate a template
field object, but I cannnot instantiate a ItemTemplate object (the
ItemTemplate class doesn't exist) to subsequently add my checkbox. What is
the procedure?

Thanks - Hedge
Oct 17 '06 #2
That did it.. Thank you!

Hedge

"Steve Edmans" wrote:
You need to create your own class that implements the ITemplate interface.

The following link shows an example of one.

http://msdn2.microsoft.com/en-us/lib...latefield.aspx

Steve

"Tony Hedge" wrote:
This seems more diffciult than it should be, can someone provide any insight?
Platform is VB 2005, gridview on a web page.

I have this code in the aspx file of a GridView control:

<asp:TemplateField >
<ItemTemplate>
<asp:CheckBox ID="chkNotifierAdd" runat="server"/>
</ItemTemplate>
</asp:TemplateField>

I need to add the TemplateField, ItemTemplate, and Checkbox controls all
programatically, not hard wired in the aspx. I can instantiate a template
field object, but I cannnot instantiate a ItemTemplate object (the
ItemTemplate class doesn't exist) to subsequently add my checkbox. What is
the procedure?

Thanks - Hedge
Oct 17 '06 #3

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

Similar topics

1
by: ABC | last post by:
I have an idea. I need to write a common gridview block which contains labels, textboxs, one girdview and some buttons. Then, I think the above block will apply on several girdview with...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
5
by: Dick | last post by:
I have a GridView bound to an ObjectDataSource. I have a Button that calls GridView.DataBind. I want the row that is selected before the DataBind to still be selected afterwards. This happens...
1
by: joechipubik | last post by:
I have a GridView in a FormView that has as its datasource a DataTable that is stored in the session cache. When I first load the page the GridView is displayed correctly, but on subsequent loads...
2
by: antonyliu2002 | last post by:
I've been googling for some time, and could not find the solution to this problem. I am testing the paging feature of gridview. I have a very simple web form on which the user can select a few...
5
by: Andrew Robinson | last post by:
I am attempting to better automate a Pager Template within a GridView. I am succesfully skinning a Drop Down List withing my control (the DDL is added to my control). I correctly populate the item...
0
by: LiamLiamLiam | last post by:
G'day all. I having a problem with my formview. I'll ty to explain my situation as best as i can. I have a page with a search field at the top which is just a simple asp:textbox. Below that i...
2
by: GISmatters | last post by:
I have unbound checkboxes in a nested gridview to allow multi-selection of "child" rows. For context, the parent gridview rows are for large "reports", the child rows are for various specific files...
4
by: Peter | last post by:
I want to call a JavaScript on PageIndexChanged event, how do I do that? Thank You Peter
3
by: Peter | last post by:
I have a GridView which is populated by List<ofObjects> Does anyone have example of how to sort the columns of this GridView? I have found examples without DataSourceControl but these use...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.