all groups > asp.net datagrid control > november 2005 >
You're in the

asp.net datagrid control

group:

Complex DataGrid


Complex DataGrid zhuang
11/4/2005 6:59:19 AM
asp.net datagrid control: Hi,

Based on the article I have read so far, I know we could customize
datagrid at column level, how about cell level?


What I want to achieve is the datagrid only have one column, some cells
are just like normal BoundColumn, some of them are comboBox. Is it
possible?


Thanks
Re: Complex DataGrid S.M. Altaf [MVP]
11/5/2005 12:00:00 AM

Hi,

I don't know what article you're talking about but it is quite possible to
customize your datagrid at even the cell level. What you can do is to use
the ItemDataBound event, (or in any subroutine loop through the
DataGridItemCollection) and actually add controls or remove controls from a
cell. This way you can have a column with a cell containing a combobox, and
the next one with a textbox.

It'd be best in your case if you set that column as a template column to
start with. Then in your template, add whatever controls you feel can be
present in the cell. Now when binding the datagrid, the ItemDataBound event
will fire. You can look for the control
(e.Cells(0).FindControl("controlname")) and hide it, or set its value, or
replace it with a literal containing the text you want from the dataset.

HTH
Altaf

--------------------------------------------------------------------------------
All that glitters has a high refractive index.
www.mendhak.com


[quoted text, click to view]

AddThis Social Bookmark Button