This is a migrated thread and some comments may be shown as answers.

Creating a Text Area

1 Answer 346 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
CoolAggie
Top achievements
Rank 1
CoolAggie asked on 16 Nov 2010, 06:49 PM
I followed your example Grid / Update/Insert/Delete in Hierarchy (http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/threelevel/defaultcs.aspx ) and did my own grid with my data. The Apps works just fine. I used the defaultVB.aspx example
My question is for example how can i make Contact Name or Company a text Area when i edit. When you click on edit it is just like a textbox.

In this example http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/extractvalues/defaultcs.aspx
Shipping address is a textarea but i am not able to find where shipping address is defined as text area.

Thanks
 

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 19 Nov 2010, 12:07 PM
Hello,

The textbox in the second demo is set to multi-line mode by setting the column editor programmatically in code-behind. Please examine the following part of the code:

Private Sub RadGrid1_CreateColumnEditor(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCreateColumnEditorEventArgs) Handles RadGrid1.CreateColumnEditor
    If (TypeOf e.Column Is GridBoundColumn) Then
        If (e.Column.UniqueName = "ShipAddress") Then
            e.ColumnEditor = New MultiLineTextBoxColumnEditor
        ElseIf (e.Column.UniqueName = "OrderDate") Then
            e.ColumnEditor = New DateColumnEditor
        End If
    End If
End Sub

Private Class MultiLineTextBoxColumnEditor
    Inherits GridTextColumnEditor
    Private MyTextBox As TextBox
 
    Protected Overrides Sub LoadControlsFromContainer()
        Me.MyTextBox = CType(Me.ContainerControl.Controls(0), TextBox)
    End Sub
 
    Public Overrides ReadOnly Property IsInitialized() As Boolean
        Get
            If Not Me.MyTextBox Is Nothing Then
                Return True
            Else
                Return False
            End If
        End Get
    End Property
 
    Public Overrides Property Text() As String
        Get
            Return Me.MyTextBox.Text()
        End Get
        Set(ByVal Value As String)
            Me.MyTextBox.Text = Value
        End Set
    End Property
 
    Protected Overrides Sub AddControlsToContainer()
        Me.MyTextBox = New TextBox
        Me.MyTextBox.ToolTip = "Custom multi-line text editor"
        Me.MyTextBox.TextMode = TextBoxMode.MultiLine
        Me.MyTextBox.Rows = 4
        Me.MyTextBox.Columns = 40
        Me.MyTextBox.BackColor = (CType(New WebColorConverter().ConvertFromString("#EDEDED"), Color))
        Me.ContainerControl.Controls.Add(Me.MyTextBox)
    End Sub
End Class

You can also enable the multi-line mode declaratively:
            ....
            <telerik:GridBoundColumn DataField="MyDataField"  ColumnEditorID="ColumnEditor1" />
         </Columns>
     </MasterTableView>
 </telerik:RadGrid>
....
 <telerik:GridTextBoxColumnEditor TextBoxMode="MultiLine" ID="ColumnEditor1" runat="server" />

Best regards,
Daniel
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
General Discussions
Asked by
CoolAggie
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or