By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,240 Members | 791 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,240 IT Pros & Developers. It's quick & easy.

Datagrid with dynamic columns does not fire SelectedIndexChanged

P: n/a
I have an application with a datagrid. In the IDE I have 2 template
columns. The first has an image button and the second contains a link

According to the results that I get back I must add more columns to the

This is a sample of how I am adding these colums:

templateColumn = New TemplateColumn
templateColumn.HeaderText = "Number"
templateColumn.SortExpression = "112"
templateItem = New columnTemplate
templateItem.ColumnName = "Number"
templateColumn.ItemTemplate = templateItem

AddHandler dgResults.SelectedIndexChanged, AddressOf

Once I bind the datagrid and get my result set back I see the datagrid
with all my values. Every field has a __doPostBack event associated to
it. If I understand correctly, ASP.NET automatically generates this
code and I cannot modify it.

If I click on one of the first 2 columns which were template columns in
the IDE, I see the Page_Load fire, then the datagrid's
SelectedIndexChanged followed by the Page_PreRender event. THis works

My problem is that if I click on one of the columns that I generated
dynamically The Page_Load will fire and then the Page_PreRender event.
The datagrid's SelectedIndexChanged does NOT fire.

I have tried the AddHandler to wire the SelectedIndexChanged event.

I am trying to understand why all of these are hotlinked but they are
not all behaving the same. I need to get the SelectedIndexChanged from
the dynamic columns.

Nov 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.