Please help with a DropDownList in a GridView

Discussion in 'ASP.NET 2.0' started by Penobscot, Feb 7, 2006.

  1. Will you please help with part of a web page? This web page has a DropDownList located in a TemplateField of a GridView. The DDL should change the image that is shown in the next column of the GridView.


    For example:
    When DDL item 1 is selected, then the next column displays: ~/images/a
    When DDL item 2 is selected, then the next column displays: ~/images/b
    When DDL item 3 is selected, then the next column displays: ~/images/c



    This is what I have done so far:


    The value of the DDL contains the path to the images.
    For example:
    The value for item 1 is: ~/images/a
    The value for item 2 is: ~/images/b and etc?


    Then, I double clicked on the DDL to create this VB code:


    Partial Class PageName
    Inherits System.Web.UI.Page


    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)


    End Sub


    End Class


    This is where I am stuck. I think that something else needs to be set up with the SelectedIndexChanged. However, I am not a programmer yet, so I do not understand how to finish.


    I am using VB in the code behind of a web page that is designed with Visual Web Developer 05 Express.


    Thanks for your help.
     
  2. You need to set AutoPostBack=true on the DDL so that everytime a selection is changed it fires the event. (SelectedIndexChanged)
     

Share This Page