p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).

Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 28th, 2008, 11:15 AM
Authorized User
 
Join Date: Oct 2006
Location: , , .
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Default SelectedIndex in datalist

I have a datalist that bind several dropdownlists from various tables. Well two of the dropdownlist are dependent upon the other. For example, if ddl1.SelectedValue = "1" then ddl2.selectedvalue = '01'. If ddl1.SelectedValue ="2" then ddl2.selectedvalue = '02'. If it was outside of a datalist then I would have no problem doing it. But instead this datalist is really throwing me off. Any suggestions. I'm not sure whether or not to use ItemDataBound or dlSelectedIndexChange. Here my code that I have thus far. Right now it's throwing the error "Object reference not specified" on the line
 'prmCauseDetail.Value = ddlcausetype.SelectedItem.Value'

Private Sub BindCauseDetails(ByVal ddl As DropDownList)

        connFF = New SqlConnection(Application("connFF"))
        Dim ddlcausetype As DropDownList
        Dim intCounter As Integer
        Dim ddlCauseDetails As DropDownList
        Dim cmdCauseDetails As New SqlCommand("spFFGetCauseDetails", connFF)
        cmdCauseDetails.CommandType = CommandType.StoredProcedure

        Dim prmCauseDetail As New SqlParameter("@CauseType", SqlDbType.VarChar)
        prmCauseDetail.Value = ddlcausetype.SelectedItem.Value
        cmdCauseDetails.Parameters.Add(prmCauseDetail)

        Dim dtrDetails As SqlDataReader

        Try
            connFF.Open()
            dtrDetails = cmdCauseDetails.ExecuteReader
            ddlCauseDetails.DataSource = dtrDetails
            ddlCauseDetails.DataTextField = "Details"
            ddlCauseDetails.DataValueField = "Details"
            ddlCauseDetails.DataBind()

            dtrDetails.Close()
            connFF.Close()

        Catch er As Exception
            LogError(er.ToString, "CauseDetails-Incident.aspx")
            Exit Try
        Finally
            connFF.Close()
        End Try
    End Sub

    Sub dlIncident_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dlIncident.SelectedIndexChanged
        Dim ddlCausedetails As DropDownList
        BindCauseDetails(ddlCausedetails)
    End Sub

<asp:DropDownList id="ddlcausetype" runat="server" OnSelectedIndexChanged="dlIncident_SelectedIndexCh anged"
                                        Width="272px" ForeColor="Gray" AutoPostBack="True"></asp:DropDownList></TD>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to set selectedindex azitanosrati General .NET 16 December 1st, 2006 02:25 PM
GridView.SelectedIndex Prop SteveP55419 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 October 8th, 2006 10:08 PM
selectedIndex is NULL or not an Object lewdogg BOOK: Beginning JavaScript 0 September 28th, 2006 10:29 AM
DropDownList selectedindex retrieval poison_king ASP.NET 1.0 and 1.1 Professional 5 September 21st, 2004 10:44 AM
Grab SelectedIndex Number phungleon Classic ASP Basics 6 May 18th, 2004 11:14 AM



All times are GMT -4. The time now is 11:18 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc