I spent my whole day but I could not solve the problem. I dont have much experience in Asp.net. Please help... DropDownList dont send selected value to the Sub DropDown_SelectedIndexChanged

The Error Message is:Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 38: Protected WithEvents ItemDropDown As System.Web.UI.WebControls.DropDownList
Line 39: Sub DropDown_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
Line 40: Dim x As String= ItemDropDown.SelectedItem.Value
Line 41: label.Text= x
Line 42: End Sub

<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<script language="VB" Debug="true" runat="server">


Sub Page_Load(Source As Object, E As EventArgs)
If Not IsPostBack Then
bindDataGrid
End If
End Sub

Sub bindDataGrid
Dim myConn As SqlConnection
Dim mySqlAdapter As SqlDataAdapter
Dim connStr, sqlStr As String
Dim myDataSet As New Dataset
connStr="server=SELIM; uid=xxxx; pwd=xxxx; Database=TestFiles"


sqlStr="SELECT * FROM TestFiles"

myConn= New SqlConnection(connStr)
myConn.Open()
mySqlAdapter=New SqlDataAdapter(sqlStr,myConn)
mySqlAdapter.Fill(myDataSet,"Sarkilar")
FileList.DataSource=myDataSet.Tables("Sarkilar")
FileList.DataBind()
myConn.Close()
End Sub

Protected WithEvents ItemDropDown As System.Web.UI.WebControls.DropDownList
Sub DropDown_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim x As String= ItemDropDown.SelectedItem.Value
label.Text= x
End Sub

Sub doPaging(s As Object, e As DataGridPageChangedEventArgs)
FileList.CurrentPageIndex=e.NewPageIndex
bindDataGrid
End Sub

</script>

<html>

<body bgcolor="#E5F2D8">
<form runat="server">

<p><font face="Verdana" size="1" Color="#669933" ><center>
(Mozilla Kullanicilarinin dosyayi indirdikten sonra dosyanin uzantisinida mp3 olarak degistirmeleri gerekmektedir)
</center></font></p>


<asp:DataGrid id="FileList" runat="server"
BorderColor="Gray"
BorderWidth="2"
CellPadding="4"

ShowHeader="true"
Align="center"
AutoGenerateColumns="false"
AllowPaging="true" PageSize="10"
PagerStyle-Mode="NumericPages"
PagerStyle-HorizontalAlign="Center"
OnPageIndexChanged="doPaging"
>

<HeaderStyle BorderColor="white" BackColor="#669933"
ForeColor="White"
Font-Bold="True"
Font-Name="Arial"
Font-Size="9" HorizontalAlign="Center"/>

<Columns>

<asp:TemplateColumn HeaderText="Sarki Ismi">
<ItemTemplate>
<b>
<font face="arial" size="1" Color="#336633">
<%# DataBinder.Eval(Container.DataItem, "MyFileName") %>
</b>
</font>
</ItemTemplate>
</asp:TemplateColumn>


<asp:TemplateColumn HeaderText="Dosya Uzantisi">
<ItemTemplate>
<b>
<font face="arial" size="1" Color="#336633">
<%# DataBinder.Eval(Container.DataItem, "FileType") %>
</b>
</font>
</ItemTemplate>
</asp:TemplateColumn>

<asp:TemplateColumn HeaderText="Dosyayi Indir">
<ItemTemplate>
<b>
<font face="arial" size="1" Color="#336633">
<a href="indir.aspx?ID=<%# DataBinder.Eval(Container.DataItem, "ID") %>">
Indir</a>
</b>
</font>
</ItemTemplate>
</asp:TemplateColumn>


<asp:TemplateColumn HeaderText="Puanlama">
<ItemTemplate>
<b>
<font face="arial" size="1" Color="#336633">
<%# DataBinder.Eval(Container.DataItem, "ID") %>
</b>
</font>
</ItemTemplate>
</asp:TemplateColumn>

<asp:TemplateColumn HeaderText="Oy Ver">
<ItemTemplate>
<asp:DropDownList ID="ItemDropDown" Runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="DropDown_SelectedIndexChanged">
<asp:ListItem Selected="True" Text="Puan Ver"/>
<asp:ListItem Value="1" Text="1"/>
<asp:ListItem Value="2" Text="2"/>
<asp:ListItem Value="3" Text="3"/>
<asp:ListItem Value="4" Text="4"/>
<asp:ListItem Value="5" Text="5"/>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateColumn>

</Columns>

</asp:DataGrid>

</form>

<asp:label id="label" runat="server"/>
<body>
</html>

selam,

1-yapmak istedigin sey nedir?
2-autopostback ten haberin var mi?

kolay gelsin

Try this instead;

Dim x As String= ItemDropDown.SelectedValue

Oh and use CODE tags around your code when posting in daniweb forums.

selim,

if you change autopostback property of dropdownlistbox to TRUE, that will help you. and you can use Dim x As String= dropdownlistbox1.text it like this. let us know what happend.

thanks