• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 289
  • Last Modified:

Need to to know how to Reset or Clear Dropdowns when another dropdown changes its value

when I change an event in dropdownlist1.. how can i clear the settings in dropdownlist 2 & 3.

Select Event:  dropdownlist1
  Professional Development Course - December 2009
  Strategies for Cultivating Respect for Diversity

Select Month:  dropdownlist2
  blank Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec

Select Year:   dropdownlist3
  blank 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020
0
westdh
Asked:
westdh
  • 11
  • 8
  • 3
  • +1
1 Solution
 
Reza RadCommented:
dropdownlist2.SelectedIndex=-1
dropdownlist2.SelectedText=""

dropdownlist3.SelectedIndex=-1
dropdownlist3.SelectedText=""



0
 
westdhAuthor Commented:
I tried this and it did not work on title change


    Protected Sub DroplistData_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

        Dim dtVolumeOrder As New DataTable()

        'Where strTitle = '" + DroplistData.SelectedValue + "'"
        Dim strSelectCommand As String = "SELECT strTitle FROM i2Integration_EventRegv45_Event"
        Using sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings("SiteSqlServer").ConnectionString)
            Using adapPatientBills As New SqlDataAdapter(strSelectCommand, sqlConn)
                adapPatientBills.Fill(dtVolumeOrder)
            End Using
        End Using
        ddlMth.SelectedIndex = -1
        ddlMth.SelectedValue = ""

        ddlYear.SelectedIndex = -1
        ddlYear.SelectedValue = ""

        DroplistData.DataSource = dtVolumeOrder
        DroplistData.DataTextField = "strTitle"
        DroplistData.DataBind()

    End Sub
0
 
Reza RadCommented:
what do you mean exactly?
with this code your ddlMth and ddlYear has no selected item then. now what you want?

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
westdhAuthor Commented:
These are the two dropdownlist I am tying to clear when I change the selected value in the ddl number 3

<asp:DropDownList ID="ddlMth" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlMth_SelectedIndexChanged">
<asp:ListItem Value=""> </asp:ListItem>
<asp:ListItem Value="1">Jan</asp:ListItem>
<asp:ListItem Value="2">Feb</asp:ListItem>
<asp:ListItem Value="3">Mar</asp:ListItem>
<asp:ListItem Value="4">Apr</asp:ListItem>
<asp:ListItem Value="5">May</asp:ListItem>
<asp:ListItem Value="6">Jun</asp:ListItem>
<asp:ListItem Value="7">Jul</asp:ListItem>
<asp:ListItem Value="8">Aug</asp:ListItem>
<asp:ListItem Value="9">Sep</asp:ListItem>
<asp:ListItem Value="10">Oct</asp:ListItem>
<asp:ListItem Value="11">Nov</asp:ListItem>
<asp:ListItem Value="12">Dec</asp:ListItem>
</asp:DropDownList>

Select Year:
<asp:DropDownList ID="ddlYear" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlYear_SelectedIndexChanged">
<asp:ListItem Value=""> </asp:ListItem>
<asp:ListItem Value="2009">2009</asp:ListItem>
<asp:ListItem Value="2010">2010</asp:ListItem>
<asp:ListItem Value="2011">2011</asp:ListItem>
<asp:ListItem Value="2012">2012</asp:ListItem>
<asp:ListItem Value="2013">2013</asp:ListItem>
<asp:ListItem Value="2014">2014</asp:ListItem>
<asp:ListItem Value="2015">2015</asp:ListItem>
<asp:ListItem Value="2016">2016</asp:ListItem>
<asp:ListItem Value="2017">2017</asp:ListItem>
<asp:ListItem Value="2018">2018</asp:ListItem>
<asp:ListItem Value="2019">2019</asp:ListItem>
<asp:ListItem Value="2020">2020</asp:ListItem>
<asp:ListItem Value="2021">2021</asp:ListItem>
<asp:ListItem Value="2022">2022</asp:ListItem>
<asp:ListItem Value="2023">2023</asp:ListItem>
<asp:ListItem Value="2024">2024</asp:ListItem>
<asp:ListItem Value="2025">2025</asp:ListItem>
</asp:DropDownList>

this is my call to dll#3
Protected Sub DroplistData_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

        Dim dtVolumeOrder As New DataTable()

        'Where strTitle = '" + DroplistData.SelectedValue + "'"
        Dim strSelectCommand As String = "SELECT strTitle FROM i2Integration_EventRegv45_Event"
        Using sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings("SiteSqlServer").ConnectionString)
            Using adapPatientBills As New SqlDataAdapter(strSelectCommand, sqlConn)
                adapPatientBills.Fill(dtVolumeOrder)
            End Using
        End Using
        ddlMth.SelectedIndex = -1
        ddlMth.SelectedValue = ""

        ddlYear.SelectedIndex = -1
        ddlYear.SelectedValue = ""

        DroplistData.DataSource = dtVolumeOrder
        DroplistData.DataTextField = "strTitle"
        DroplistData.DataBind()

    End Sub

0
 
Reza RadCommented:
If you use Items.Clear all items in dropdown will clear, do you mean this? if yes look at code below:

Protected Sub DroplistData_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

        Dim dtVolumeOrder As New DataTable()

        'Where strTitle = '" + DroplistData.SelectedValue + "'"
        Dim strSelectCommand As String = "SELECT strTitle FROM i2Integration_EventRegv45_Event"
        Using sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings("SiteSqlServer").ConnectionString)
            Using adapPatientBills As New SqlDataAdapter(strSelectCommand, sqlConn)
                adapPatientBills.Fill(dtVolumeOrder)
            End Using
        End Using
        ddlMth.Items.Clear()

        ddlYear.Items.Clear()

        DroplistData.DataSource = dtVolumeOrder
        DroplistData.DataTextField = "strTitle"
        DroplistData.DataBind()

    End Sub

Open in new window

0
 
westdhAuthor Commented:
No i do not want to clearout all Items in the ddl's
0
 
Reza RadCommented:
so if you don't want to clear all, I suggested ddlMth.SelectedIndex=-1 and ddlMthSelectedText="", what is your problem in this way?
0
 
westdhAuthor Commented:
 these do not have any effect    on the ddl, the dll does not change from it previous setting

         ddlMth.SelectedIndex = -1
         ddlMth.SelectedText = ""

also thier is no ddlMth.SelectedText = ""

thier is a ddlMth.SelectedValue = ""
0
 
Reza RadCommented:
a question:
Is it asp.net page or windows application? if it is asp.net page,bring your page_load code here.


you can use:
ddlMth.SelectedItem.Text="" instead of ddlMth.SelectedText=""


0
 
westdhAuthor Commented:
I don;t know ...still no effect.
0
 
westdhAuthor Commented:
Tags:
asp.net v3.5 dropdownlist vb Add Tags
0
 
Reza RadCommented:
OK,
I think you need to change place of your code like below:


Protected Sub DroplistData_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

        Dim dtVolumeOrder As New DataTable()

        'Where strTitle = '" + DroplistData.SelectedValue + "'"
        Dim strSelectCommand As String = "SELECT strTitle FROM i2Integration_EventRegv45_Event"
        Using sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings("SiteSqlServer").ConnectionString)
            Using adapPatientBills As New SqlDataAdapter(strSelectCommand, sqlConn)
                adapPatientBills.Fill(dtVolumeOrder)
            End Using
        End Using

DroplistData.DataSource = dtVolumeOrder
        DroplistData.DataTextField = "strTitle"
        DroplistData.DataBind()

        ddlMth.SelectedIndex = -1
        ddlMth.SelectedValue = ""

        ddlYear.SelectedIndex = -1
        ddlYear.SelectedValue = ""

        

    End Sub

Open in new window

0
 
westdhAuthor Commented:
This did not work either
0
 
Reza RadCommented:
could you upload all your .aspx and .vb code here?
0
 
westdhAuthor Commented:
aspx page
---------------------

<%@ Page Language="VB" Debug="true" AutoEventWireup="false" CodeFile="EventRegRpt.aspx.vb" Inherits="wwwroot_EventRegRpt" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<HTML id="HTML1" runat="Server">
<head id="Head1" runat="Server">

</head>
<body id="Body1" align="center" runat="server">
<table align="center" width="1024">
<tr><td align="center"><strong><font size="4">CMAA Northern California Event Registration Report</font></strong></td></tr>
<tr><td align="center"><font size="1">Print Instructions: Print in preview mode - Set to Landscape - Set Shrink Page to 85% - Click on Print preview.</font>
</td></tr>

<tr align="center"><td>
<form align="center" id="form1" runat="server">
<br />
Select Event Name:
<asp:DropDownList ID="DroplistData" runat="server" Width="340px"  AutoPostBack="True" SelectedIndexChanged="DroplistData_SelectedIndexChanged">
<asp:ListItem> </asp:ListItem>
</asp:DropDownList>
<br /><br />
Select Month:
<asp:DropDownList ID="ddlMth" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlMth_SelectedIndexChanged">
<asp:ListItem Value=""> </asp:ListItem>
<asp:ListItem Value="1">Jan</asp:ListItem>
<asp:ListItem Value="2">Feb</asp:ListItem>
<asp:ListItem Value="3">Mar</asp:ListItem>
<asp:ListItem Value="4">Apr</asp:ListItem>
<asp:ListItem Value="5">May</asp:ListItem>
<asp:ListItem Value="6">Jun</asp:ListItem>
<asp:ListItem Value="7">Jul</asp:ListItem>
<asp:ListItem Value="8">Aug</asp:ListItem>
<asp:ListItem Value="9">Sep</asp:ListItem>
<asp:ListItem Value="10">Oct</asp:ListItem>
<asp:ListItem Value="11">Nov</asp:ListItem>
<asp:ListItem Value="12">Dec</asp:ListItem>
</asp:DropDownList>

Select Year:
<asp:DropDownList ID="ddlYear" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlYear_SelectedIndexChanged">
<asp:ListItem Value=""> </asp:ListItem>
<asp:ListItem Value="2009">2009</asp:ListItem>
<asp:ListItem Value="2010">2010</asp:ListItem>
<asp:ListItem Value="2011">2011</asp:ListItem>
<asp:ListItem Value="2012">2012</asp:ListItem>
<asp:ListItem Value="2013">2013</asp:ListItem>
<asp:ListItem Value="2014">2014</asp:ListItem>
<asp:ListItem Value="2015">2015</asp:ListItem>
<asp:ListItem Value="2016">2016</asp:ListItem>
<asp:ListItem Value="2017">2017</asp:ListItem>
<asp:ListItem Value="2018">2018</asp:ListItem>
<asp:ListItem Value="2019">2019</asp:ListItem>
<asp:ListItem Value="2020">2020</asp:ListItem>
<asp:ListItem Value="2021">2021</asp:ListItem>
<asp:ListItem Value="2022">2022</asp:ListItem>
<asp:ListItem Value="2023">2023</asp:ListItem>
<asp:ListItem Value="2024">2024</asp:ListItem>
<asp:ListItem Value="2025">2025</asp:ListItem>
</asp:DropDownList>

<br />
<br />
  <asp:GridView ID="uxItemDetailGrid" runat="server" ShowFooter="true" AutoGenerateColumns="false"  HorizontalAlign="center" HeaderStyle-Height="80" CellPadding="2"  BorderColor="#A1C1D9"  GridLines="Both" RowStyle-Font-Size="8" width="1024">
        <HeaderStyle backcolor="#5D7B9D" font-bold="True" forecolor="White" /><FooterStyle backcolor="#5D7B9D" font-bold="True" forecolor="White" />
        <Columns>
            <asp:TemplateField  ItemStyle-BackColor = "#F4F4F4" HeaderStyle-BackColor="#A1C1D9"   HeaderStyle-Font-Size="9"  HeaderText="Event<br>Date">
                <ItemTemplate>
                    <asp:Label ID="lblEventDate" runat="server"  BackColor = "#F4F4F4"
                            Text='<%# Eval("dtmEvent") %>'>
                    </asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField ItemStyle-BackColor = "#F4F4F4" ItemStyle-HorizontalAlign="Left" HeaderStyle-BackColor="#A1C1D9" HeaderStyle-Font-Size="9" HeaderText="Event<br>Title">
                <ItemTemplate>
                    <asp:Label ID="lblTitle" runat="server" BackColor = "#F4F4F4"
                            Text='<%# Eval("strTitle") %>'>
                    </asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField ItemStyle-BackColor = "#F4F4F4" ItemStyle-HorizontalAlign="Left" HeaderStyle-BackColor="#A1C1D9" HeaderStyle-Font-Size="9" HeaderText="Company<br>Name">
                <ItemTemplate>
                    <asp:Label ID="lblstrName" runat="server" BackColor = "#F4F4F4"
                            Text='<%# Eval("strName") %>'>
                    </asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField ItemStyle-BackColor = "#F4F4F4"  ItemStyle-HorizontalAlign="Left" HeaderStyle-BackColor="#A1C1D9" HeaderStyle-Font-Size="9" HeaderText="Company<br>Email">
                <ItemTemplate>
                    <asp:Label ID="lblstrEmail" runat="server" BackColor = "#F4F4F4"
                            Text='<%# Eval("strEmail") %>'>
                    </asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
                <asp:TemplateField ItemStyle-BackColor = "#F4F4F4" ItemStyle-HorizontalAlign="Left" HeaderStyle-BackColor="#A1C1D9" HeaderStyle-Font-Size="9" HeaderText="Attendee<br>Name">
                <ItemTemplate>
                    <asp:Label ID="lblUserName" runat="server" BackColor = "#F4F4F4"
                            Text='<% #Eval("strRegistrationUserName") %>'>
                    </asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
           
               <asp:TemplateField ItemStyle-BackColor = "#F4F4F4" ItemStyle-HorizontalAlign="Left" HeaderStyle-BackColor="#A1C1D9" HeaderStyle-Font-Size="9" HeaderText="Attendee<br>Email" FooterStyle-Font-Size="9" FooterText="Event Total">
                <ItemTemplate>
                    <asp:Label ID="lblstrBadgeName" runat="server" BackColor = "#F4F4F4"
                            Text='<% #Eval("strBadgeName") %>'>
                    </asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
           
                  <asp:TemplateField ItemStyle-BackColor = "#F4F4F4" ItemStyle-HorizontalAlign="Center" HeaderStyle-BackColor="#A1C1D9" HeaderStyle-Font-Size="9" HeaderText="Fee<br>Amount">
                <ItemTemplate>
                    <asp:Label ID="lblfltOrderAmount" runat="server" BackColor = "#F4F4F4"
                            Text='<% #Eval("fltOrderAmount","{0:c}")  %>'>
                    </asp:Label>
                </ItemTemplate>
                <ItemTemplate>
                        <%#GetUnitPrice(Decimal.Parse(Eval("fltOrderAmount").ToString())).ToString("N2")%>
                    </ItemTemplate>
                    <FooterTemplate>
                        <%# GetTotal().ToString("N2") %>
                    </FooterTemplate>
            </asp:TemplateField>
           
            <asp:TemplateField ItemStyle-BackColor = "#F4F4F4" ItemStyle-HorizontalAlign="Center" HeaderStyle-BackColor="#A1C1D9" HeaderStyle-Font-Size="9" HeaderText="Sent<br>Email">
                <ItemTemplate>
                    <asp:Label ID="lblblnEmailSent" runat="server" BackColor = "#F4F4F4"
                            Text='<% #Eval("blnEmailSent") %>'>
                    </asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
           
             <asp:TemplateField ItemStyle-BackColor = "#F4F4F4" ItemStyle-HorizontalAlign="Left" HeaderStyle-BackColor="#A1C1D9" HeaderStyle-Font-Size="9" HeaderText="Date Attendee<br>Registered">
                <ItemTemplate>
                    <asp:Label ID="lbldtmCreated" runat="server" BackColor = "#F4F4F4"
                            Text='<% #Eval("dtmCreated") %>'>
                    </asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
 
        </Columns>
    </asp:GridView>
    <br />
     <asp:Label ID="Label1"  runat="server" Text="To print labels export to excel."></asp:Label>
    <br />
   <!-- <asp:Button ID="btnExportWord" runat="server" Text="ExportToWord" OnClick="btnExportWord_Click" /> -->
    <asp:Button ID="btnExportExcel" runat="server" Text="ExportToExcel" OnClick="btnExportExcel_Click" />
</form>
</td></tr>
</table>

<table align="center" width="800">
<tr><td align="center">This Schedule is for CMAA Norcal Records only.</td></tr>
</table>
</body>
</HTML>

=======================

aspx.vb page

+++++++++++

Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Collections
Imports System.IO
Imports System.Text
Imports System.Xml
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls

Partial Public Class wwwroot_EventRegRpt
    Inherits System.Web.UI.Page
    Private iRowsCount As Integer = 0

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load

        If Not IsPostBack Then

            Dim dtVolumeOrder As New DataTable()
            Dim strSelectCommand As String = "SELECT e.dtmEvent,e.strTitle,r.strName,r.strEmail,u.strRegistrationUserName,u.strBadgeName,r.fltOrderAmount,r.blnEmailSent,r.dtmCreated FROM i2Integration_EventRegv45_Event e,i2Integration_EventRegv45_Registration r, i2Integration_EventRegv45_RegistrationUser u where e.intEventID = r.intEventID and r.intRegistrationID = u.intRegistrationID and r.blnEmailSent=1 Order by e.dtmEvent"
            Using sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings("SiteSqlServer").ConnectionString)
                Using adapPatientBills As New SqlDataAdapter(strSelectCommand, sqlConn)
                    adapPatientBills.Fill(dtVolumeOrder)
                End Using
            End Using

            uxItemDetailGrid.DataSource = dtVolumeOrder
            uxItemDetailGrid.DataBind()

            Dim dtVolumeOrder2 As New DataTable()
            Dim strSelectCommand2 As String = "SELECT distinct(strTitle) FROM i2Integration_EventRegv45_Event"
            Using sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings("SiteSqlServer").ConnectionString)
                Using adapPatientBills As New SqlDataAdapter(strSelectCommand2, sqlConn)
                    adapPatientBills.Fill(dtVolumeOrder2)
                End Using
            End Using

            DroplistData.DataSource = dtVolumeOrder2
            DroplistData.DataTextField = "strTitle"
            DroplistData.DataBind()
 
        End If
    End Sub

    Protected Sub DroplistData_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

        Dim dtVolumeOrder As New DataTable()

        'Where strTitle = '" + DroplistData.SelectedValue + "'"
        Dim strSelectCommand As String = "SELECT strTitle FROM i2Integration_EventRegv45_Event"
        Using sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings("SiteSqlServer").ConnectionString)
            Using adapPatientBills As New SqlDataAdapter(strSelectCommand, sqlConn)
                adapPatientBills.Fill(dtVolumeOrder)
            End Using
        End Using

        DroplistData.DataSource = dtVolumeOrder
        DroplistData.DataTextField = "strTitle"
        DroplistData.DataBind()

        ddlMth.SelectedIndex = -1
        ddlMth.SelectedValue = ""

        ddlYear.SelectedIndex = -1
        ddlYear.SelectedValue = ""


    End Sub

    Protected Sub ddlMth_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

        Dim dtVolumeOrder As New DataTable()
        Dim strSelectCommand As String = "SELECT e.dtmEvent,e.strTitle,r.strName,r.strEmail,u.strRegistrationUserName,u.strBadgeName, r.fltOrderAmount, r.blnEmailSent,r.dtmCreated FROM i2Integration_EventRegv45_Event e,i2Integration_EventRegv45_Registration r, i2Integration_EventRegv45_RegistrationUser u where e.intEventID = r.intEventID and r.intRegistrationID = u.intRegistrationID and r.blnEmailSent=1 and(YEAR(e.dtmEvent) = '" + ddlYear.SelectedValue + "' AND MONTH(e.dtmEvent) = '" + ddlMth.SelectedValue + "' AND e.strTitle = '" + DroplistData.SelectedValue + "') Order by e.dtmEvent"
        Using sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings("SiteSqlServer").ConnectionString)
            Using adapPatientBills As New SqlDataAdapter(strSelectCommand, sqlConn)
                adapPatientBills.Fill(dtVolumeOrder)
            End Using
        End Using
        'iRowsCount = dtVolumeOrder.Rows.Count - 1
        uxItemDetailGrid.DataSource = dtVolumeOrder
        uxItemDetailGrid.DataBind()

    End Sub

    Protected Sub ddlYear_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

        Dim dtVolumeOrder As New DataTable()
        Dim strSelectCommand As String = "SELECT e.dtmEvent,e.strTitle,r.strName,r.strEmail,u.strRegistrationUserName,u.strBadgeName, r.fltOrderAmount,r.blnEmailSent,r.dtmCreated FROM i2Integration_EventRegv45_Event e,i2Integration_EventRegv45_Registration r, i2Integration_EventRegv45_RegistrationUser u where e.intEventID = r.intEventID and r.intRegistrationID = u.intRegistrationID and r.blnEmailSent=1 and(YEAR(e.dtmEvent) = '" + ddlYear.SelectedValue + "' AND MONTH(e.dtmEvent) = '" + ddlMth.SelectedValue + "' AND e.strTitle = '" + DroplistData.SelectedValue + "') Order by e.dtmEvent"
        Using sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings("SiteSqlServer").ConnectionString)
            Using adapPatientBills As New SqlDataAdapter(strSelectCommand, sqlConn)
                adapPatientBills.Fill(dtVolumeOrder)
            End Using
        End Using
        'iRowsCount = dtVolumeOrder.Rows.Count - 1
        uxItemDetailGrid.DataSource = dtVolumeOrder
        uxItemDetailGrid.DataBind()
    End Sub

    Public Overloads Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
        ' Verifies that the control is rendered
    End Sub
    Protected Sub OnPaging(ByVal sender As Object, ByVal e As GridViewPageEventArgs)
        uxItemDetailGrid.PageIndex = e.NewPageIndex
        uxItemDetailGrid.DataBind()
    End Sub

    Protected Sub btnExportWord_Click(ByVal sender As Object, ByVal e As EventArgs)

        Response.Clear()
        Response.Buffer = True
        'For Word:
        Response.AddHeader("content-disposition", "attachment;filename=datafile.doc")
        Response.ContentType = "application/vnd.ms-word"
        'For Excel Response.AddHeader("content-disposition", "attachment;filename=data.xls"); Response.ContentType = "application/vnd.ms-excel";
        Response.Charset = ""
        Me.EnableViewState = False
        Dim oStringWriter As New System.IO.StringWriter()
        Dim oHtmlTextWriter As New System.Web.UI.HtmlTextWriter(oStringWriter)
        uxItemDetailGrid.RenderControl(oHtmlTextWriter)
        Response.Write(oStringWriter.ToString())
        Response.[End]()

    End Sub

    Protected Sub btnExportExcel_Click(ByVal sender As Object, ByVal e As EventArgs)
        Response.Clear()
        Response.Buffer = True
        'For Word:
        'Response.AddHeader("content-disposition", "attachment;filename=data.doc")
        'Response.ContentType = "application/vnd.ms-word"
        'For Excel
        Response.AddHeader("content-disposition", "attachment;filename=data.xls")
        Response.ContentType = "application/vnd.ms-excel"
        Response.Charset = ""
        Me.EnableViewState = False
        Dim oStringWriter As New System.IO.StringWriter()
        Dim oHtmlTextWriter As New System.Web.UI.HtmlTextWriter(oStringWriter)
        uxItemDetailGrid.RenderControl(oHtmlTextWriter)
        Response.Write(oStringWriter.ToString())
        Response.[End]()
    End Sub

End Class
0
 
CodeCruiserCommented:
You have empty items at the top of both dropdowns so try setting the SelectedIndex = 0. No need to set the text or value.
0
 
sir plusSales ManagementCommented:
If that doesnt do it then I would delete and recreate them each time.
Not perhaps eloquent but will work...........
0
 
westdhAuthor Commented:
I have tried everything this forum as suggestioned ...it seems that all of the above suggestions (commands) are not finding the ddlmth or ddlYear
0
 
CodeCruiserCommented:
Are these DDLs inside some other container such as a datalist, a detailsview etc?
0
 
westdhAuthor Commented:
No here is a simple example of my problem with two ddl's
----------------------------------------------------------------------------------
First set ddlYear to a date like 2009
then set the DroplistData to a test value and hope that the 'ddlYear' will return to index of zero
================================================
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Collections
Imports System.IO
Imports System.Text
Imports System.Xml
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls

Partial Public Class wwwroot_EventRegRptest
    Inherits System.Web.UI.Page
    Private iRowsCount As Integer = 0

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load

        If Not IsPostBack Then

        End If
    End Sub

    Protected Sub DroplistData_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

        ddlYear.SelectedIndex = 0

        'ddlYear.SelectedValue = 0
        'ddlYear.Items(0).Selected = True
        'ddlYear.DataTextField = "2010"
        'ddlYear.DataBind()

        'ddlYear.SelectedValue = ddlYear.Items.IndexOf(ddlYear.Items.FindByValue(""))
        'ddlYear.SelectedIndex = 0
        'ddlYear.DataBind()
    End Sub

End Class

========================

<%@ Page Language="VB" Debug="true" AutoEventWireup="false" CodeFile="EventRegRptest.aspx.vb" Inherits="wwwroot_EventRegRptest" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html id="HTML1" runat="Server">
<head id="Head1" runat="Server">

</head>
<body id="Body1" align="center" runat="server">
<table align="center" width="1024">
<tr align="center"><td>
<form align="center" id="form1" runat="server">
<br />
Select Event Name:
<asp:DropDownList ID="DroplistData" runat="server" Width="340px"  AutoPostBack="True" SelectedIndexChanged="DroplistData_SelectedIndexChanged">
<asp:ListItem> </asp:ListItem>
<asp:ListItem Value="1">test 1</asp:ListItem>
<asp:ListItem Value="2">test 2</asp:ListItem>
<asp:ListItem Value="3">test 3</asp:ListItem>
</asp:DropDownList>
<br /><br />

Select Year:
<asp:DropDownList ID="ddlYear" runat="server" AutoPostBack="true" >
<asp:ListItem Value=""> </asp:ListItem>
<asp:ListItem Value="2009">2009</asp:ListItem>
<asp:ListItem Value="2010">2010</asp:ListItem>
<asp:ListItem Value="2011">2011</asp:ListItem>
<asp:ListItem Value="2012">2012</asp:ListItem>
<asp:ListItem Value="2013">2013</asp:ListItem>
<asp:ListItem Value="2014">2014</asp:ListItem>
<asp:ListItem Value="2015">2015</asp:ListItem>
<asp:ListItem Value="2016">2016</asp:ListItem>
<asp:ListItem Value="2017">2017</asp:ListItem>
<asp:ListItem Value="2018">2018</asp:ListItem>
<asp:ListItem Value="2019">2019</asp:ListItem>
<asp:ListItem Value="2020">2020</asp:ListItem>
<asp:ListItem Value="2021">2021</asp:ListItem>
<asp:ListItem Value="2022">2022</asp:ListItem>
<asp:ListItem Value="2023">2023</asp:ListItem>
<asp:ListItem Value="2024">2024</asp:ListItem>
<asp:ListItem Value="2025">2025</asp:ListItem>
</asp:DropDownList>

</form>
</td></tr>
</table>
</body>
</HTML>


0
 
westdhAuthor Commented:
Found the answer. the event was not firing
0
 
Reza RadCommented:
Glad to solve,
Thanks for points,
Regards,

0
 
CodeCruiserCommented:
A correct comment should have been selected as the answer. Only saying that so that someone else landing at this page may be surprized to see the accepted solution of the problem!
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

  • 11
  • 8
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now