Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 12th, 2007, 10:30 AM
Registered User
 
Join Date: Apr 2007
Location: Glasgow, , United Kingdom.
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
        Response.write("Called")
        Dim drop as DropDownList = DirectCast(Me.FormView1.Row.FindControl("pTextBox" ), DropDownList)
        if Not drop Is Nothing then
            Response.Write(":: FOUND CONTROL")
                        drop.Enabled = False
        Else
            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!

Stevie

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 12:04 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.