Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 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 Professional 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
  #1 (permalink)  
Old March 19th, 2007, 02:22 PM
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dynamically creating TemplateField....

Hello,

How to Create TemplateField Dynamically for DetailsView in asp.net??

My code is as under:
-------------------------

<script runat="server">
    Sub page_load()
        Dim tf As New TemplateField()
        Dim t As New TextBox()
        t.Text = "aDj"

        t = tf.InsertItemTemplate()
        DetailsView1.Fields.Add(tf)
        ' DetailsView1.Fields(2).HeaderText = "OK"

        Response.Write("HEfrLLo")
        DetailsView1.Fields.Add(t)
        'DetailsView1.Rows(2).TemplateControl = DetailsView1.FooterTemplate
    End Sub
</script>
------------------------------


Compiler Error Message: BC30311: Value of type 'System.Web.UI.WebControls.TextBox' cannot be converted to 'System.Web.UI.WebControls.DataControlField'.

Thanks



  #2 (permalink)  
Old March 19th, 2007, 02:26 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there..

i don't know about your question.. but check this out:

if t is a textbox, you are doing t = tf.InsertItemTemplate() and that could be an error.. don't you want to do the way around?? insert t into tf and then insert tf into the detailview????

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating Xpath Dynamically ajayreddy2105 XSLT 2 February 20th, 2007 08:30 AM
Creating Conrols dynamically jamil umar ASP.NET 1.0 and 1.1 Basics 3 February 13th, 2006 01:02 PM
dynamically creating control rahulpokharna Pro VB Databases 1 January 10th, 2006 04:41 PM
Creating controls dynamically Renu ASP.NET 1.0 and 1.1 Basics 9 December 19th, 2004 10:21 AM
Dynamically creating an array youngj PHP How-To 0 November 8th, 2004 03:42 AM





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