Button Column added at run time does not seem to trigger SelectIndexChanged Event.

J

Jim Mitchell

I have the following button column added to the datagrid. It does not seem
to trigger SelectIndexChanged.

Is there something else I have to do? Thanks in advance.

dcolumn = New System.Web.UI.WebControls.ButtonColumn

dcolumn.ButtonType = ButtonColumnType.LinkButton

dcolumn.DataTextField = "Contact"

dcolumn.HeaderText = "Contact"

dcolumn.CommandName = "Select"

dgAccountPages.Columns.Add(dcolumn)
 
J

Jim Mitchell

The key for me was that you have to databind() on postback. I had one
datagrid's selectedindexchange event adding controls to a second datagrid
and databinding the second datagrid in the selectindexchange event of the
first datagrid. On postback, I did not think I needed to databind, so the
controls dissapeared or did not fire events. I guess I have to change my
structure a bit and set a flag as to the type of postback and add the
controls to the second datagrid on postback of the page.
 

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,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top