Click here to Skip to main content
15,887,267 members
Home / Discussions / ASP.NET
   

ASP.NET

 
Questionnot able to generate crystal report. Pin
durgesh j27-Jul-13 23:09
durgesh j27-Jul-13 23:09 
AnswerRe: not able to generate crystal report. Pin
Richard MacCutchan28-Jul-13 1:07
mveRichard MacCutchan28-Jul-13 1:07 
GeneralAny online quiz module Pin
durgesh j27-Jul-13 22:51
durgesh j27-Jul-13 22:51 
SuggestionRe: Any online quiz module Pin
Richard MacCutchan28-Jul-13 1:06
mveRichard MacCutchan28-Jul-13 1:06 
AnswerRe: Any online quiz module Pin
ZurdoDev29-Jul-13 4:46
professionalZurdoDev29-Jul-13 4:46 
QuestionUsing Microsoft II7 in a Intel Atom N270 Pin
Jean A Brandelero26-Jul-13 10:15
Jean A Brandelero26-Jul-13 10:15 
AnswerRe: Using Microsoft II7 in a Intel Atom N270 Pin
NotPolitcallyCorrect26-Jul-13 16:12
NotPolitcallyCorrect26-Jul-13 16:12 
QuestionDropDownList's SelectedIndexChanged event is not triggered Pin
cpp_prgmer26-Jul-13 9:56
cpp_prgmer26-Jul-13 9:56 
I read several posts online & verified the following: 1. AutoPostBack="true" 2. EnableViewState="True" (default) 3. CausesValidation = "False" (default) Also added the EnableViewState="true" on the page-level directive. Inspite of this I am unable to cause the SelectedIndexChanged event to trigger. I am using VS2010, VB.NET with no AJAX. I am populating my dropdownlist in the PageLoad event and on the condition If (Not IsPostback) Another issue is that my dropdownlist items are getting cleared on postback each time. So as a work around I added SQLDataSource on my aspx page and configured it as datasource to my dropdownlist and now the event is getting triggered properly, I am not sure why.

I am new to VB.NET and web development and I feel I am missing something obvious, like taking into consideration Page events chronology, please suggest. Thanks for all your help in advance.

ASP.NET
<%@ Page Title="" Language="VB" MasterPageFile="~/MyMaster.master" AutoEventWireup="false" CodeFile="MyPage.aspx.vb" Inherits="MyPage" EnableViewState="true" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="MainPageContent" Runat="Server">
<center><h3>Title</h3></center><br />
 
<table width="500px">
    <tr>
        <td><asp:Label ID="Label1" Text="Label1 : " runat="server"></asp:Label></td>
         <td><asp:DropDownList ID="ddl1" Width="200px" runat="server"
                AutoPostBack="True"/></td>
    </tr>
    <tr><td></td></tr>
     <tr>
        <td><asp:Label ID="Label2" Text="Label2 : " runat="server"></asp:Label></td>
        <td><asp:DropDownList ID="ddl2" Width="200px" runat="server" 
                AutoPostBack="True" /></td>
    </tr>
    <tr><td></td></tr>
    <tr>
        <td><asp:Label ID="Label3" Text="Label3 : " runat="server"></asp:Label></td>
         <td><asp:DropDownList ID="ddl3" Width="200px" runat="server" 
                AutoPostBack="True" /></td>
    </tr>
</table><br />
 <asp:Label ID="lblError" ForeColor="Red" runat="server" />
</asp:Content>

Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration.ConfigurationManager

Partial Class MyPage Inherits System.Web.UI.Page
    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
         If IsPostBack Then
            Exit Sub
        End If
        PopulateData()
    End Sub

    Private Sub PopulateData()
        Dim da As New SqlDataAdapter
         Dim ds1, ds2, ds3 As New DataSet

        Try
            Using conn As New SqlConnection(ConnectionStrings.Item("DataConnectionString").ToString)
                Using cmd As New SqlCommand("MySP1", conn)
                     cmd.CommandType = CommandType.StoredProcedure
                    conn.Open()
                    da.SelectCommand = cmd
                    da.Fill(ds1)
                    cmd.CommandText = "MySP2"
                     da.SelectCommand = cmd
                    da.Fill(ds2)
                    cmd.CommandText = "MySP3"
                    da.SelectCommand = cmd
                    da.Fill(ds3) 
                    conn.Close()
                End Using
            End Using

            ddl1.DataSource = ds1.Tables(0)
            ddl1.DataValueField = "Col1"
            ddl1.DataTextField = "Col2"
            ddl1.DataBind()
            ddl1.Items.Insert(0, New ListItem(String.Empty, String.Empty))
            ddl1.SelectedIndex = 0

            ddl2.DataSource = ds2.Tables(0)
            ddl2.DataValueField = "Col1"
            ddl2.DataTextField = "Col2"
            ddl2.DataBind()
            ddl2.Items.Insert(0, New ListItem(String.Empty, String.Empty))
            ddl2.SelectedIndex = 0
 
            ddl3.DataSource = ds3.Tables(0)
            ddl3.DataValueField = "Col1"
            ddl3.DataTextField = "Col2"
            ddl3.DataBind()
            ddl3.Items.Insert(0, New ListItem(String.Empty, String.Empty))
            ddl3.SelectedIndex = 0

        Catch ex As Exception
            'todo get a proper error message here
            lblError.Text = "Error"
        End Try

    End Sub
 
    Protected Sub ddl_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles ddl1.SelectedIndexChanged, ddl2.SelectedIndexChanged, ddl3.SelectedIndexChanged
        ClientScript.RegisterStartupScript(Me.GetType(), "myalert", "alert('" & "test" & "');", True)
    End Sub
End Class

AnswerRe: DropDownList's SelectedIndexChanged event is not triggered Pin
Parwej Ahamad26-Jul-13 18:45
professionalParwej Ahamad26-Jul-13 18:45 
GeneralRe: DropDownList's SelectedIndexChanged event is not triggered Pin
cpp_prgmer28-Jul-13 9:18
cpp_prgmer28-Jul-13 9:18 
QuestionHow to send some data from an Asp.Net app to another Asp.Net app? Pin
Mohammed Hameed26-Jul-13 9:01
professionalMohammed Hameed26-Jul-13 9:01 
AnswerRe: How to send some data from an Asp.Net app to another Asp.Net app? Pin
Parwej Ahamad26-Jul-13 18:52
professionalParwej Ahamad26-Jul-13 18:52 
AnswerRe: How to send some data from an Asp.Net app to another Asp.Net app? Pin
ZurdoDev29-Jul-13 4:47
professionalZurdoDev29-Jul-13 4:47 
QuestionI am recent very high honor college graduates with A.S. Degree in Computer Programming, and I really want to be a good .NET developer. Pin
TheWorldofWonders26-Jul-13 6:16
TheWorldofWonders26-Jul-13 6:16 
AnswerRe: I am recent very high honor college graduates with A.S. Degree in Computer Programming, and I really want to be a good .NET developer. Pin
Mohammed Hameed26-Jul-13 9:18
professionalMohammed Hameed26-Jul-13 9:18 
Questiongeting Error!The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters in creating pdf using iTextsharp in asp.net Pin
Member 1005684026-Jul-13 1:20
Member 1005684026-Jul-13 1:20 
AnswerRe: geting Error!The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters in creating pdf using iTextsharp in asp.net Pin
ZurdoDev29-Jul-13 4:48
professionalZurdoDev29-Jul-13 4:48 
QuestionProblems with Windows 7 and IE10, Update Panel, embedded Jquery scripts Pin
jkirkerx25-Jul-13 17:07
professionaljkirkerx25-Jul-13 17:07 
AnswerRe: Problems with Windows 7 and IE10, Update Panel, embedded Jquery scripts Pin
ZurdoDev29-Jul-13 4:50
professionalZurdoDev29-Jul-13 4:50 
GeneralRe: Problems with Windows 7 and IE10, Update Panel, embedded Jquery scripts Pin
jkirkerx29-Jul-13 6:40
professionaljkirkerx29-Jul-13 6:40 
GeneralDeleted Post Pin
jkirkerx25-Jul-13 5:53
professionaljkirkerx25-Jul-13 5:53 
GeneralRe: IE10 and updatepanel with image button Pin
Richard Deeming25-Jul-13 6:33
mveRichard Deeming25-Jul-13 6:33 
GeneralThat was posted 2 years ago Pin
jkirkerx25-Jul-13 7:10
professionaljkirkerx25-Jul-13 7:10 
QuestionHow to give image path which located in other system in asp.net Pin
ven75322-Jul-13 2:15
ven75322-Jul-13 2:15 
AnswerRe: How to give image path which located in other system in asp.net Pin
Brij23-Jul-13 18:33
mentorBrij23-Jul-13 18:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.