Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 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 April 12th, 2007, 10:30 AM
Registered User
Join Date: Apr 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default DropDownList Inside FormView Problem

Hey there,

Im quite new to ASP.NET and need some help to complete this project. What I'm trying to do is disable a DropDownList within a FormView depending what level of user logs into the page. Now what I have is a DropDownList in an EditTemplate of the FormView but not in the ItemTemplate (So that lets say the Admin User comes along and wants to change a City of a user... He Goes into the Edit mode of FormView and selects the new city for the user ... if a normal user logs in then he cant change this field so the DropDownList should be disabled). Ok with that explained I have this bit of code to catch when the Edit Button is pressed:

private Sub FormView1_DataBound(ByVal sender As Object, ByVal e As FormViewCommandEventArgs) Handles FormView1.ItemCommand
      If e.CommandName.Equals("Edit") Then
        Dim drop as DropDownList = DirectCast(Me.FormView1.Row.FindControl("pTextBox" ), DropDownList)
        if Not drop Is Nothing then
            Response.Write(":: FOUND CONTROL")
                        drop.Enabled = False
            Response.Write(":: NOT FOUND CONTROL :- NULL")
        End if
      End If
    end sub

Now what happens is when i press the edit button .. the Sub is called and prints out NOT FOUND CONTROL:- NULL

I modified the code so that it would call the above sub anytime the event changed to see what was happening (commented out the line [ If e.CommandName.Equals("Edit") Then]) and the Sub is called and prints out NOT FOUND CONTROL:- NULL but when i hit the cancel or update button the response is FOUND CONTROL (back when the ItemTemplate is shown not the edittemplate)

Now im so confused as to why it cant find the DropDownList in the Edit Template but can find it when it goes back to the ItemTemplate. If anyone can give me any help with this then it will be much appriciated. Thanks everyone!


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
'FormView' must be placed inside a form tag stephena.co.uk ASP.NET 2.0 Basics 2 October 15th, 2008 08:25 AM
FormView - access DropDownList controls kgaughan ASP.NET 2.0 Basics 0 July 29th, 2008 01:40 PM
FormView/ObjectDataSource/DropDownList Problem davidanderson ASP.NET 2.0 Professional 3 April 14th, 2007 02:50 AM
DropDownList Inside a datagrid @shish ASP.NET 1.0 and 1.1 Professional 3 January 29th, 2007 07:24 PM

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