dynamic events for dropdownlist not working in datagrid

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
 
G

Guest

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

HTH

Pete
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top