Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 16th, 2005, 01:39 PM
Friend of Wrox
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to load specific value from dropdown list?

Hi guys. i have an editable datagrid that has a edit button next to
each record.once i click on it goes to a new page and loads the specifc record in edit mode and allow me edit the values. one of the values is in drop down box as u can see in the pic below. The problem that i have it always loads the first value from drop downlist not value coresponding to the record. I be happy if some one help me fixt this problem.thanks

http://i5.photobucket.com/albums/y18...7/datagrid.jpg (datagrid pic)

http://i5.photobucket.com/albums/y18...7/editmode.jpg (edit page)

http://i5.photobucket.com/albums/y18...designview.jpg ( edit form in deisign view)

http://i5.photobucket.com/albums/y18...7/19932c0e.jpg (db reletions)

my onload and update code :


    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        MyConnection = New SqlConnection("server=localhost;database=teniss2;uid=web;pwd=web;")
        If Not IsPostBack Then

            SqlSelectCommand1.Parameters(0).Value = Convert.ToInt16(Request.QueryString("match"))

            SqlDataAdapter1.Fill(DataSet11, "matches")





            SqlDataAdapter2.Fill(DataSetplayerteamMatches1, "Players")

        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim MyCommand As SqlCommand

        Dim UpdateCmd As String = "Update Matches Set Teamno=" & Me.TeamNolable.Text & ", playerno=" & Me.DropDownList1.SelectedValue & ", won=" & Me.TextBox1.Text & ", lost=" & Me.TextBox2.Text & _
                    " Where MatchNo = " & MatchNolable.Text

        MyCommand = New SqlCommand(UpdateCmd, MyConnection)

    End Sub
Old June 17th, 2005, 08:08 AM
planoie's Avatar
Friend of Wrox
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

You need to set the selected item of the DDL. You aren't doing that anywhere.

DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.Fi ndByValue("<value from database here>"))


Similar Threads
Thread Thread Starter Forum Replies Last Post
fill dropdown list with items when parent list isaac_cm Pro PHP 1 July 10th, 2006 05:41 AM
Load a data form with a specific searched record zpluug VB.NET 1 October 9th, 2005 05:38 AM
Load two variables into Dropdown list tryntolearn Classic ASP Databases 2 August 12th, 2005 09:25 AM
How to get a list of specific tag from xml using v JelfMaria XML 4 January 13th, 2005 09:34 AM
dropdown list not selecting record on page load whyulil ASP.NET 1.0 and 1.1 Basics 1 September 8th, 2004 08:29 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.