| | |
DropDownList dont send selected value to the Sub DropDown_SelectedIndexChanged
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2006
Posts: 3
Reputation:
Solved Threads: 0
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
ataGrid 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
ropDownList 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
ropDownList>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp
ataGrid>
</form>
<asp:label id="label" runat="server"/>
<body>
</html>
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
ataGrid 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
ropDownList 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
ropDownList></ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp
ataGrid></form>
<asp:label id="label" runat="server"/>
<body>
</html>
•
•
Join Date: Apr 2006
Posts: 62
Reputation:
Solved Threads: 0
Re: DropDownList dont send selected value to the Sub DropDown_SelectedIndexChanged
0
#2 Jul 12th, 2006
Re: DropDownList dont send selected value to the Sub DropDown_SelectedIndexChanged
0
#3 Jul 12th, 2006
Try this instead;
Oh and use [HTML][/HTML] tags around your code when posting in daniweb forums.
ASP.NET Syntax (Toggle Plain Text)
Dim x As String= ItemDropDown.SelectedValue
Oh and use [HTML][/HTML] tags around your code when posting in daniweb forums.
Last edited by hollystyles; Jul 12th, 2006 at 10:17 am.
•
•
Join Date: Apr 2006
Posts: 62
Reputation:
Solved Threads: 0
Re: DropDownList dont send selected value to the Sub DropDown_SelectedIndexChanged
0
#4 Jul 13th, 2006
![]() |
Similar Threads
- dropdownlist value doesnt get selected (ASP)
- Java Progamming with Z39.50 attributes (Java)
- "Send" keeps running (Windows Software)
- Windows media player (Windows NT / 2000 / XP)
- Windows Send Error Reports (Windows NT / 2000 / XP)
- iexplorer.exe send error reports(1 too many) (Web Browsers)
Other Threads in the ASP.NET Forum
- Previous Thread: How to Populate listbox2
- Next Thread: Validation difficulties *sigh*
| Thread Tools | Search this Thread |
.net 2.0 3.5 ajax alltypeofvideos appliances asp asp.net beginner box browser businesslogiclayer button c# c#gridviewcolumn cac checkbox class compatible confirmationcodegeneration content contenttype countryselector courier dataaccesslayer database datagrid datagridview datalist deployment development dgv dialog dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv forms gridview gudi homeedition iis javascript jquery list listbox menu microsoft mouse mssql nameisnotdeclared news novell numerical opera order panelmasterpagebuttoncontrols problem radio ratings redirect registration relationaldatabases reportemail schoolproject search security serializesmo.table sessionvariables silverlight smoobjects software sql sql-server ssl tracking treeview validatedate validation vb.net videos vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopment webprogramming webservice xml xsl






