Results 1 to 3 of 3

Thread: Event Handling Problem

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    Tokyo, Japan
    Posts
    72

    Question Event Handling Problem

    Hello

    I am having 2 combo boxes (dropdownlists) on ASPX Page. If value is changed in first dropdownlist, values in 2nd dropdownlist should be changed accordingly. For this I am trying to write Event Handling Code.

    But it is giving me error

    Compiler Error Message: BC30506: Handles clause requires a WithEvents variable.

    Code is as follows :

    Sub ddlChiiki_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlChiiki.SelectedIndexChanged
    Dim AL as ArrayList = new ArrayList()
    Dim Temp1, Temp2 as string
    If File.Exists(csvPath & sCSVFileName) = True Then
    Try
    ' Open the file to read from.
    sr = File.OpenText(csvPath & sCSVFileName)
    sr.ReadLine()
    Do While sr.Peek() >= 0
    Dim txtTemp=Split(sr.ReadLine(), txtDelimiter)
    Temp1 = txtTemp(1)
    Temp2 = txtTemp(3)
    If ddlChiiki.SelectedItem.Text = Temp1 Then
    AL.Add(Temp2)
    End If
    Loop
    sr.Close()

    ddlPam1.DataSource = AL
    ddlPam1.DataBind()

    Catch x As Exception
    Response.Write(x.ToString())
    End Try
    End If
    End Sub

    <aspropDownList id="ddlChiiki" runat="server" OnSelectedIndexChanged="ddlChiiki_SelectedIndexChanged" AutoPostBack="True" Width="120px"></aspropDownList>

    Pls suggest something earliest.

    [What is exact meaning of Handles, AddHandler, etc. ?]

    Thanks
    Mahesh
    Everybody is always learning something new !

  2. #2
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092
    Are you using Code Behind or script blocks on your page?

    You should have something like this
    VB Code:
    1. Inherits System.Web.UI.Page
    2. Protected WithEvents ddlChiiki As System.Web.UI.WebControls.DropDownList
    at the top of your page

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    Tokyo, Japan
    Posts
    72
    Hello

    Event Handling problem has been solved. Anyhow it is working fine now.

    Thanks
    Mahesh
    Everybody is always learning something new !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width