Wrox Programmer Forums
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 November 9th, 2006, 08:54 PM
Authorized User
Join Date: Nov 2005
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default Gridview and dropdownlist


I have a dropdownlist embedded in a gridview, my problem is that when i edit a row and the drop down list appears, the default value is the first value in the list not the value of the record being edited.

I try to get the current value as follows
Protected Sub gEmployee_RowEditing ....
  sStatus = gEmployee.Rows(e.NewEditIndex).Cells(3).Text

  gEmployee.EditIndex = e.NewEditIndex
End Sub

and change the displayed value
 Protected Sub gEmployee_PreRender ...
    Dim d As DropDownList
    d = gEmployee.FindControl("eEmpType")
    If Not IsNothing(d) Then
       d.SelectedIndex = d.Items.IndexOf(d.Items.FindByText(sStatus))
    End If
End Sub

But sStatus never gets assigned a value therefore prerender always throws an exception. Can anyone suggest what i am doing wrong.



Similar Threads
Thread Thread Starter Forum Replies Last Post
Two DropDownList Inside a Gridview ilayaraja ASP.NET 3.5 Basics 3 December 5th, 2008 06:26 PM
DropDownList in Gridview sdoremus ASP.NET 3.5 Basics 0 September 15th, 2008 07:15 PM
Gridview and DropDownList extendedram ASP.NET 2.0 Basics 3 June 12th, 2007 04:05 PM
Binding dropdownlist to gridView mcgarry101 ASP.NET 2.0 Basics 0 February 13th, 2007 07:12 AM
Cascading DropDownList in a GridView Aaron Edwards ASP.NET 2.0 Basics 0 January 12th, 2007 02:11 PM

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