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

Multiline Edit From RadGrid Not Working

1 Answer 79 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 03 Jun 2014, 06:59 PM
I have a RadGrid From that I have the AutoEdit Turned on - I am am trying to make a couple of the Fields in the "PopUp" Edit Form be multiline as they are of type Ntext and are large. Currently they are just smaller type default Text Cells and cannot see all of the text. Trying to get them to be Multiline and maybe Scrollable.. Below is my code that I have behind in my .aspx.vb code for the page - but it is not making anything happen.

For Edit item.

Protected Sub RadGrid2_ItemDataBound(sender As Object, e As 
GridItemEventArgs)<BR>If TypeOf e.Item Is GridEditFormItem AndAlso 
e.Item.IsInEditMode Then<BR>Dim editItem As GridEditFormItem = TryCast(e.Item, 
GridEditFormItem)<BR>Dim editTable As Table = 
TryCast(TryCast(editItem.EditFormCell, 
GridEditFormItem.EditFormTableCell).Controls(7).Controls(7), 
Table)<BR>editTable.Width = Unit.Percentage(100)<BR>Dim textBox As TextBox = 
DirectCast(editItem("Corrective Action").Controls(7), 
TextBox)<BR>textBox.TextMode = TextBoxMode.MultiLine<BR>TryCast(textBox.Parent, 
TableCell).Width = Unit.Percentage(100)<BR>textBox.Width = 
Unit.Percentage(100)<BR>End If<BR>End Sub

For Create Item

Protected Sub RadGrid2_ItemCreated(sender As Object, e As 
GridItemEventArgs)<BR>If TypeOf e.Item Is GridEditFormItem AndAlso 
e.Item.IsInEditMode Then<BR>Dim editItem As GridEditFormItem = TryCast(e.Item, 
GridEditFormItem)<BR>Dim editTable As Table = 
TryCast(TryCast(editItem.EditFormCell, 
GridEditFormItem.EditFormTableCell).Controls(7).Controls(7), 
Table)<BR>editTable.Width = Unit.Percentage(100)<BR>Dim textBox As TextBox = 
DirectCast(editItem("Corrective Action").Controls(7), 
TextBox)<BR>textBox.TextMode = TextBoxMode.MultiLine<BR>TryCast(textBox.Parent, 
TableCell).Width = Unit.Percentage(100)<BR>textBox.Width = 
Unit.Percentage(100)<BR>End If<BR>End Sub

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 04 Jun 2014, 07:10 AM
Hi Alex,

You need to use only one event to set a textbox to Multiline. You can use the ItemDataBound, and I see that your function definition is not correct. Please try the following code snippet.

VB:
Protected Sub RadGrid1_ItemDataBound(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound
  If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then
    Dim editItem As GridEditableItem = DirectCast(e.Item, GridEditableItem)
    Dim txtAction As TextBox = DirectCast(editItem("CorrectiveAction").Controls(0), TextBox)
    txtAction.TextMode = TextBoxMode.MultiLine
  End If
End Sub

Thanks,
Shinu
Tags
Grid
Asked by
Alex
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or