Template Column...

M

Mike Andrews

Guys,

I've got a problem with a ASP.NET 1.1 Datagrid that I wanted to see if any
of you had any suggestions or advice on how to correct. My original problem
with the datagrid was that I had 4 pre-defined columns. However, due to a
feature restriction I needed to make the first column invisible. This had
the undesired side effect of making the right-most border of the datagrid
disappear. However, when I deleted the column (in code) then the right-most
border displayed correctly. However, using the radio-button list control
(that I had on the page), and changing the selected item from one option to
another, the grid magically got the deleted row back even though in code I
could test and the grid only returned back three columns, not four, yet four
appear.
So, what I thought I'd do was create the columns dynamically at runtime that
way there could be no ambiguity as to how many columns there should be.
Template columns are much more difficult to produce at runtime. It turns out
you need to create a class that implements the Itemplate interface. I did
all that and stored my image button control in it and it works. Except that
when you click the button, the datagrid's ItemCommand event will not fire
and the grid disappears off of the screen. This is unacceptable.

I was wondering if any of you have ever done anything like this before or
have had this happen to you and if you know how I might overcome it.

Thanks,
Mike
 
E

Elton Wang

Hi Mike,

Is it possible to just remove the first column at all (not by programming)
since you don't need it?
 
M

Mike Andrews

Elton,

I've tried that already but it produces deleterious side effects. I need
the column in some cases and don't in others. I've tried making it
invisible and deleting it altogether but to no avail. Nothing seems to work
properly.

Thanks,
Mike
 
D

Darren Kopp

Changing a columns visibility should not affect the borders of a
datagrid. It simply does not render that column. Are you using CSS on
the datagrid? How are you defining that the column's visibility is set
to false (ie as a declarative property on the datagrid, or
programatically in your code). Also, make sure that in the button's
event that you rebind the grid, that's probably why it's disappearing.

Relevant code is always helpful.

HTH,
Darren Kopp
http://blog.secudocs.com/
 
E

Elton Wang

If purpose of the invisible column is to store data, the better way is to
store data in DataKeyField, then retrieving by
datagrid.DataKeys[e.Item.ItemIndex].



HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top