View Single Post
  #14 (permalink)  
Old 08-03-2007, 05:09 AM
JSureshkumar JSureshkumar is offline
D-Web Sr.Programmer
 
Join Date: Feb 2007
Location: in someone's heart
Posts: 139
JSureshkumar is on a distinguished road
Send a message via Skype™ to JSureshkumar
Smile Re: Implementation Data Controls in asp.net

Hi,
if you need this checkbox to appear for each DataSet, you can still use ItemTemplate in your GridView declaration. Then you can add your dynamically created columns.
However, if you only need this checkbox is some cases, you needto add TemplateField column to your grid and assign ItemTemplate property. You need to have instance of a class implementing ITemplate interface to assign it to ITemTemplate property.
To get this instanace you can:
1. Create a UserContorl with CheckBox inside and load it using LoadTemplate method of your page
2. Use sample class and code from: It Could Be Done!: Implementing ITemplate as Anonymous Method
1. This sample uses Button instead of CheckBox, just need to replace
2. This sample demonstrates implementation of ITemplate for GridView column
Note, that if you have ViewState enabled for your GridView, you will probably lose your checkbox on postback. So, this simple TemlateField sample works only for GridViews with disabled ViewState. If data binding on each postback is not acceptable for you, please ask more questions here.
__________________
J Suresh Kumar
Google Hacks
Reply With Quote