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

asp.net datagrid control

group:

Dynamically adding controls


Dynamically adding controls treilly
11/22/2005 8:13:42 PM
asp.net datagrid control:
Hi all,
I currently have a datagrid with a buttoncolumn and a few other boundcolumns.
Once a user clicks on a button in the buttoncolumn, I need to remove that
control and put another control in it's place. I am having no luck
whatsoever in doing this. I have made a new LinkButton in my code-behind (C#)
and have tried adding it to the calling row (e.item.cells[0].controls.add
(newControl)) - this seems to work as far as placing the control there.
However, once I click on it the event does not fire. I've tried a Click
event, a Command event - neither of those worked. What I really need is for
it to fire an event where I can get the DataGridCommandEventArgs for the
particular row that was clicked. I tried adding the control to the Datagrid,
but my button ends up outside the table (probably because I don't know how to
tell it to put it in the right place).

So I suppose my question would be:
Is there a way to add a linkbutton in the code-behind to a datagrid such that
it will raise the ItemClick event (and I will be able to get the
DataGridCommandEventArgs from it)?

Thanks in advance.
-TR

--
Message posted via DotNetMonster.com
Re: Dynamically adding controls S.M. Altaf [MVP]
11/25/2005 12:00:00 AM
Are you handling the ItemCommand event?
--------------------------------------------------------------------------------
All that glitters has a high refractive index.
www.mendhak.com

[quoted text, click to view]

AddThis Social Bookmark Button