|
I have dropdownlist in my gridView header which I populate on RowDataBound event.
When I am trying to add DropDownList selectedIndexChange Event in code DropDownList is not in a lits. How do I add event handler event for dropdownlist in code?
Private Sub gvMarketingPlans_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvMarketingPlans.RowDataBound
If e.Row.RowType = DataControlRowType.Header Then
Dim ddlProducts As DropDownList = DirectCast(e.Row.Cells(1).FindControl("ddlProduct"), DropDownList)
ddlProducts.Items.Clear()
With ddlProducts
.DataSource = DataSource
.DataTextField = "Description"
.DataValueField = "ProductCode"
.DataBind()
.Items.Insert(0, New ListItem("< All >", ""))
End With
End If
End Sub
|
|
|
|
|
Based on the code, it looks like a dropdownlist does exists from before. In the RowDataBound event you are trying to populate data in that pre-existing dropdown. Since, it pre-exists, you can define a selected change index for it.
In case you want to define it at runtime in RowDataBound, then you need to add this:
AddHandler ddlFilter.SelectedIndexChanged, AddressOf Me.ddl2_SelectedIndexChanged
ddlFilter.AutoPostBack = true
Private Sub ddlFilter_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
End Sub
|
|
|
|