Dynamic Datagrid

G

Guest

Hi,

I have a page that has a datagrid bound to a dataset. Items are added to
the dataset at particular times (ie the click event of an item in a tree
control) then bound to the grid. The grid has an image button in a Template
column that is used to remove an item (dataset row). I can't re-bind the
grid on the postback or I lose the event handler for the button. I also have
a column that contains a textbox that I need to handle the TextChanged event,
but because of not being able to bind on the postback, I lose the binding to
the grid before I get to the event handler. How can I either prevent or work
around this?
 
G

Guest

Maybe I can simplify my explanation.

I need to capture the value entered into the textbox when the user changes
it, but if the grid isn't re-bound on the postback, the textbox that my
quantity is entered into doesn't exist and I can't handle the event. On the
other hand, if I do re-bind on the postback, I loose the event handler for
the remove button.

Currently, I handle the remove button click (it's an image button in a
template column of the grid) in the ItemCommand event of the grid. Can I
handle the button as I would a regular button (ie. capture the click event
instead of the itemcommand event) or would that event handler be wiped out
just the same because it's within the grid? I'll try to code this, but if
someone can shed some light on this so I don't stray too far down the wrong
path, I'd appreciate it.

Thanks.
 
E

Elton Wang

Why if you rebind data source you will loose the event
handler for the remove button?

Elton Wang
(e-mail address removed)
 
G

Guest

hi mwhalen,

What you need to do is add your remove button when the row is added (and
also add the event handlers and such for the button) and handle the click
event of the button instead of using the ItemCommand event of the datagrid.
Your click event handler will not be lost if you operate it this way.

Thanks,
mwhalen
 

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

Top