Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB 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 February 17th, 2012, 09:11 PM
Friend of Wrox
 
Join Date: May 2011
Posts: 411
Thanks: 13
Thanked 7 Times in 7 Posts
Default Simple Question

If you have a details grid and you want to track information on sales leads, and customers and one of the data fields needs to be a text area, rather than a text box, what do you code in design view to make the input/display area a text area instead of a textbox?

Thanks Imar

PS How does setting this up as an Item Template differ from just the regular default field? Still a just a bit fuzzy on Item Templates.
 
Old February 18th, 2012, 12:56 AM
Friend of Wrox
 
Join Date: Nov 2009
Posts: 156
Thanks: 13
Thanked 16 Times in 16 Posts
Smile

Hi there
in the source view, create a TemplateField:
HTML Code:
<asp:DetailsView ID="x" runat="server" AutoGenerateRows="False" DataKeyNames="ID" DataSourceID="SqlDataSource1">
    <Fields>
        <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" />

       <%-- rest fields ... --%>

        <asp:TemplateField HeaderText="Special Field">
            <ItemTemplate>
                <asp:TextBox TextMode="MultiLine" Text='<%# Eval("SpecialField") %>' runat="server"></asp:TextBox>
            </ItemTemplate>
        </asp:TemplateField>

    </Fields>
</asp:DetailsView>
__________________
happy every time, happy every where

Reza Baiat

Last edited by irProject; February 18th, 2012 at 12:58 AM..
 
Old February 18th, 2012, 09:40 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
PS How does setting this up as an Item Template differ from just the regular default field? Still a just a bit fuzzy on Item Templates.
Out of the box, a regular field generates controls appropriate for the type. E.g. a TextBox for a string property.

By converting it to a TemplateField (as shown by irProject) you let ASP.NET you want to define the content yourself. You can then set up whatever controls or other content you need, and use data binding to get data in and out of your control.

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple question? Cade_Feng BOOK: Beginning Regular Expressions 3 October 18th, 2012 07:14 PM
not at all simple question petergoodman XSLT 0 July 18th, 2008 08:37 AM
simple question petergoodman XSLT 8 July 18th, 2008 07:57 AM
Very Simple Question YoungLuke C# 2 May 4th, 2007 02:23 AM
Simple question maximus101 Classic ASP Basics 2 October 18th, 2005 10:22 PM





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