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 November 24th, 2006, 03:03 PM
Authorized User
 
Join Date: Oct 2006
Posts: 20
Thanks: 1
Thanked 0 Times in 0 Posts
Default Setting an initial value for a Checkbox

I've found a way to initialize textboxes for my detailsview insert, but now I need to do the same for checkboxes (some need to start as true). The following is my code for textboxes:

Protected Sub DetailsView1_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles DetailsView1.PreRender
If DetailsView1.CurrentMode = DetailsViewMode.Insert Then
 Dim ThisControl As TextBox
 ThisControl = DetailsView1.FindControl("InsertEventName")
 ThisControl.Text = "new event"
 ThisControl = DetailsView1.FindControl("InsertDays")
 ThisControl.Text = "1"
 End if
End Sub

Frankly, I don't completely understand it all because I'm a newbie and still struggling with developing my .net skills. I've tried the obvious to make it work for checkboxes too, but when I insert this:

 Dim ThisCheck As Checkbox
 ThisCheck = DetailsView1.FindControl("RegisterOnline")
 ThisCheck.Checked = True

I get an error message that says BC30456: 'Checked' is not a member of 'System.Web.UI.Control'.

What am I missing?


 
Old December 6th, 2006, 06:45 PM
Authorized User
 
Join Date: Sep 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Why not just set it as checked in the control's "Properies" window?

 
Old December 7th, 2006, 03:05 AM
Authorized User
 
Join Date: Sep 2006
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dim ThisControl As CheckBox
 ThisControl = DetailsView1.FindControl"Name of checkBox")
thiscontol.checked= true;

Insert this block before the "ENDIF"






Similar Threads
Thread Thread Starter Forum Replies Last Post
Initial setup PHP5 rjdani Beginning PHP 1 October 16th, 2007 05:11 PM
checkbox in gridview and setting "checked" Snuffles ASP.NET 2.0 Basics 2 April 7th, 2007 05:15 AM
The ConnectionString property has not been initial mar0364 ASP.NET 1.0 and 1.1 Basics 6 March 17th, 2006 11:24 PM
Re-Initial variable to zero akibaMaila VB.NET 2002/2003 Basics 3 July 12th, 2005 01:41 PM
Setting Checkbox Checked Property from OnClick saturdave ASP.NET 1.0 and 1.1 Basics 2 April 8th, 2004 09:33 AM





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