Hi !
I have a requirement wherein i am binding a datalist which contains a label
(Caption for the field) and some literal hidden fields and a dropdown list.
When I am binding to the datalist.. only the labels (caption) and the
invisible literal controls are binded..
Now based on the invisible literal control values I get the information from
DB to bind it with each dropdown list (I am doing this in the item databound
event)
Also based on one of the literal control value i have to add the event
handler to the drop down list... e.g. Refer the code
' Code to bind the datalist
dim arlList as ArrayList
arlList = objService.GetServicesDetailsRequired(..)
dtlList.datasource = arlList
dtlList.databind()
' Now in the item databound event of the datalist --
' Get the details from DB for the given values
dim arlDetails as Arraylist =
objService.GetServiceList(Ctype(e.item.findcontrol ("litCodeType"),
Literal).Text, Ctype(e.item.findcontrol("litServiceCode"), Literal).Text)
dim ddl as dropdownlist = Ctype(e.item.findcontrol("ddlDetails"),
dropdownlist)
ddl.datasource = arlDetails
ddl.databind()
' till this point the code is working..
' now based on the current items one of the listeral controls value.. i have
to add
' the handler like e.g. if the current dropdown list depends on one of the
previous
' dropdownlist
dim currentDetailCode as string = Ctype(e.item.findControl("litCode"),
Literal).text
for each dtlItem in the datalist
if Ctype(dtlItem.findControl("litPrevDetailCode"), Literal).text =
currentDetailCode then
ddl.AutoPostBack = true
AddHandler ddl.SelectedIndexChanged, AddressOf <SomeMethodName>
end if
....
' Here my item databound code for the datalist ends
but my event handler is not invoked at runtime
what is the problem ? I am not able to understand why is it not firing the
event..
For some simple purpose one of my friend has done this in item created event
... but for him .. he knows that there will be always an event handler for the
dropdown list.. but for me its not the same situation .. i have to depend on
some binded values.. which i can access only in item databound event...
your expert advise will be highly appreciated.
Rgds
Shiju