This was something else that gave me fits recently. I have a web app that uses a formview, which wasn’t that big a deal to me. Until I tried to have the value in one dropdown affect the value(s) in a second dropdown. For my problem the first dropdown holds manufacturer names and then the second displays the models by the selected manufacturer in the first dropdown.
I could get the dropdowns to load up proper on the first load based on a SQL query, but the issue came about when I was testing changing the value of the manufacturer dropdown. None of the formview methods seemed to fire when I needed them to.
So what I did was to set the ‘OnSelectedIndexChanged’ of the manufacturer ddl. I used:
Protected Sub ddlMfr_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
for the sub. This would fire when I changed the manufacturer item. Within the sub I wrote code more specific to the dropdown lists and their respective datasources to have them populate via the datasource’s Select statement. To find the datasources I used Me.FindControl(datasource name) and for the dropdowns formview.Row.FindControl(ddl name).
Technorati Tags:
ASP.Net,
VB.Net