I expect that I'm just doing something just a smidge wrong (newly moved to web-dev from winforms, and new to Telerik). I'm updating an app that primarily has a RadGrid displaying GridBoundColumns that display text normally and turn to textboxes when the row is being edited. I'm converting one of these columns to a GridTemplateColumn that uses a RadAutoCompleteBox in the EditItemTemplate. In normal (display?) mode, the text bound to the item displays correctly, but when the row enters edit mode, the AutoCompleteBox is properly bound to its own data source, but doesn't display the grid-row's value for that column. How do I do that?
I have:
<telerik:GridTemplateColumn UniqueName="PartNumber" HeaderText="Part Number" ItemStyle-CssClass="editWidth"
FilterControlAltText="Filter PartNumber column" FilterControlWidth="85%">
<ItemTemplate><%#DataBinder.Eval(Container.DataItem, "PartNumber")%></ItemTemplate>
<EditItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "PartNumber")%>
<telerik:RadAutoCompleteBox runat="server" ID="racbPN" DataSourceID="ItemIdSource" DataTextField="IMA_ItemID"
HighlightFirstMatch="true" InputType="Text" TextSettings-SelectionMode="Single" MaxResultCount="200" MinFilterLength="4"
Delimiter="" DropDownHeight="300px" DropDownWidth="200px">
</telerik:RadAutoCompleteBox>
</EditItemTemplate>
<HeaderStyle Width="190px"></HeaderStyle>
</telerik:GridTemplateColumn>
Scouring the Telerik forums, I've seen some references to putting code in the ItemDataBound event. That code is typically in C# and my converted-to-VB implementations never work. I don't know if I'm mistranslating or they're not really the answer for my situation, but here's an example of something I've tried in the code-behind:
If e.Item.IsInEditMode Then
Dim item As GridEditableItem = e.Item
If Not e.Item Is GetType(IGridInsertItem) Then
Dim auto As RadAutoCompleteBox = CType(item.FindControl("racbPN"), RadAutoCompleteBox)
auto.Entries.Add(New AutoCompleteBoxEntry(item("PartNumber").Text, item("GSIS_AMRKey").Text))
End If
End If
Thanks for taking a look and please let me know what other info I need to provide if I've left something important out.
(Should radautocompletebox be a valid tag?)
Telerik tech support got back to me with an answer. The code I listed above in the OnItemDataBound event was almost right. This works:
If e.Item.IsInEditMode Then
If Not e.Item Is GetType(IGridInsertItem) Then
Dim partNumber As String = DirectCast(e.Item.DataItem, DataRowView)("PartNumber").ToString
Dim auto As RadAutoCompleteBox = DirectCast(e.Item.FindControl("racbPN"), RadAutoCompleteBox)
auto.Entries.Add(New AutoCompleteBoxEntry(partNumber))
End If
End If