I have wasted a lot of time today because I did not fully understand the control hiarcy of the RadGrid.
My problem was that I were not able to get the values from the editedItem controls.
My grid has a GridTemplateColumn like this
<telerik:GridTemplateColumn UniqueName="doc_name_org" HeaderText="Document">
<HeaderStyle CssClass="colored_header" Width="40%" />
<ItemStyle CssClass="colored" Width="40%" />
<asp:ImageButton ID="lnk_doc_name_org_img" Style="border: 0px; vertical-align: middle;" runat="server" />
<asp:HyperLink ID="lnk_doc_name_org_txt" runat="server"></asp:HyperLink>
<asp:TextBox ID="txtFileName" CssClass="small" Style="float: left" runat="server" Text="" Width="60%"></asp:TextBox>
<input type="button" style="float: right" causesvalidation="false" id="btnGetExtraDoc" runat="server" class="button_small" value="Get document" />
Handling the ItemTemplate was ok, but the EditItemTemplate was a bit more tricky.
Every example I came across used this methode to get the value from the textbox txtFileName
Dim DocName As String = TryCast(editedItem("doc_name_org").Controls(0), TextBox).Text
But of course it was not that simple. It turned out that I had to use .Controls(1) to get the textbox value.
I find this a bit confusing because I actually would expect the textbox to be control(0) and the button to be control(1)....
Any explenations for this? Is control(0) the ItemTemplate and Control(1) the EditTemplate?
If so, I must have missed this explenation somewhere....
To remove the posibility of messing this up later on I figured I should use another approach that does not relay on me to get the index right.
So, the following line accomplishes the same result, but more failsafe. I can add/remove controls without any damage.
Dim DocName2 As String = TryCast(e.Item.FindControl("txtFileName"), TextBox).Text
I think the examples for Telerik Controls should also demonstrate more complex implementations and give explenations for them, not just basic implementations.
Hope this helps someone.