Print Page | Close Window

declaration problem

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=21438
Printed Date: 28 March 2026 at 2:20pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: declaration problem
Posted By: __n3o__
Subject: declaration problem
Date Posted: 29 September 2006 at 12:13pm
Wonder if someone can help me? Am V new to ASP.NET and learning very slowly

I have a detailsview control and in it I have asp:textbox fields (Via a ItemTemplate).. I have created this sub and want it to auto populate the textbox's on page load....

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        If Not Page.IsPostBack Then
            dteCommentDate.Text = My.Computer.Clock.LocalTime.Date
            txtPostId.Text = Request.QueryString("news")
        End If
End Sub

Now the weird this is its asking me to declare dteCommentDate & txtPostId which are textbox's in my Details view..

BUT when I tried it out this code with just normal asp:textbox not in a details view control
<script runat="server">
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        TextBox1.Text = My.Computer.Clock.LocalTime.Date
    End Sub
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</asp:Content>

This works fine ... I am very confused can someone shed some light please??




Replies:
Posted By: michael
Date Posted: 29 September 2006 at 2:45pm
Childcontrol of that nature are not exposed to the designer. Use:

Dim x As New TextBox
x = DetailsView1.FindControl("dteCommentDate")
x.Text = My.Computer.Clock.LocalTime.Date

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net