Datagrid with dynamic columns does not fire SelectedIndexChanged

Discussion in 'ASP .Net' started by tafpin@gmail.com, Jun 8, 2005.

  1. Guest

    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
    button.

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

    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
    dgResults.Columns.Add(templateColumn)
    CheckSortHeader(templateColumn)

    AddHandler dgResults.SelectedIndexChanged, AddressOf
    dgResults_SelectedIndexChanged

    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
    fine.

    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.
    , Jun 8, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim
    Replies:
    3
    Views:
    5,679
  2. akhzar
    Replies:
    1
    Views:
    726
    akhzar
    Mar 6, 2009
  3. George
    Replies:
    1
    Views:
    204
    George
    Jan 22, 2004
  4. Brad

    Datagrid SelectedIndexChanged Does Not Fire

    Brad, Nov 25, 2003, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    126
  5. Jim

    SelectedIndexChanged event does not fire

    Jim, Mar 8, 2005, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    129
    steve-o
    Mar 8, 2005
Loading...

Share This Page