dynamic events for dropdownlist not working in datagrid

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi,
iam a having a datagrid,
pls check the code




----
Public WithEvents bgt As System.Web.UI.WebControls.DropDownList
---

If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then ' pls don't add foooter

SqlDataAdapter2.SelectCommand.CommandText = "select * from Generalledger
where active=1 and Glaccounttype='" & GLTransactionType.SelectedValue & "'
order by glaccountno "
Dim ds As New DataSet
SqlDataAdapter2.Fill(ds, "Generalledger")

bgt = e.Item.FindControl("accountid")
bgt.ID = e.Item.ItemIndex
bgt.DataMember = "GeneralLedger"
bgt.DataValueField = "AccountID"
bgt.DataSource = ds.Tables(0).DefaultView
bgt.DataTextField = "GLAccountName"
bgt.AutoPostBack = True
bgt.EnableViewState = True
bgt.DataBind()

AddHandler bgt.SelectedIndexChanged, AddressOf
onSelectedIndexChangedevent
end if

end sub
---

and i have this code

Private Sub bgt_SelectedIndexChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles bgt.SelectedIndexChanged
Response.Write("<script>alert('Evnet chanrged!!!')</script>")
Response.Write(bgt.SelectedValue())
End Sub

-------

the above bgt event is not working, how should i change, or how i modify...
pls help me

thanks
 
Have you set the AutoPostBack property of the DDL to True? If not set it and
it should fix your problem.

HTH

Pete
 
hi pete,
in the code it self i put dropdownlist autopostback is true.
but it is not working, i think this not the solution

thanks
 
Back
Top