Saturday, March 24, 2012

ListBox

hi all,

can any body help me in correcting the following code as i am not getting any kind of error but it is not being excuted, i do not know why!!!!?

code:
Protected Sub ddlViewMovieTitle_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlViewMovieTitle.SelectedIndexChanged

com = New SqlCommand("Select * from CastMovie", con)
dr = com.ExecuteReader

While dr.Read()
If ddlViewMovieTitle.SelectedValue = dr("MovieID") Then
Dim castID As Integer
castID = dr("CastID")
Dim cmd As New SqlCommand("select CastName from Cast where CastID like '" & castID & "'", con)
Dim castName As String
castName = cmd.ExecuteScalar.tosrting()
lstBoxCastName.Items.Add(castName)
End If
End While
dr.Close()

End SubDoes ddlViewMovieTitle have AutoPostBack set to True?
Do you repopulate the ddlViewMovieTitle in the Page Load event without doing a postback check?
i have unchecked the postback box now but is not working as well
it looks like you need to re-check the autopostback option of the dropdown then put your code in the DropDownList_SelectedIndexChanged event handler.
ya I you can see the code from above; similar to what you said
Postback box? I don't know what that is.

What I mean is, doing a check for Page.IsPostBack in the Page_Load event. If it evaluates to true, don't fill the listbox, else, fill it.

0 comments:

Post a Comment