I try to use FormTemplate in Grid:
...etc.
Form works perfectly.
When I try to get values on update as shown in the example http://www.telerik.com/help/aspnet-ajax/grdupdatingvaluesusercontrolformtemplate.html:
| <telerik:radgrid ID="RadGrid1" runat="server" GridLines="None" ShowGroupPanel="True" |
| Width="99%" AllowSorting="True" AllowMultiRowSelection="false" allowpaging="True" |
| pagesize="6" skin="Outlook" OnNeedDataSource="RadGrid1_NeedDataSource" |
| HorizontalAlign="NotSet" onitemcommand="ChangeAccount" |
| > |
| <MasterTableView AutoGenerateColumns="false" DataKeyNames="Username" |
| CommandItemDisplay="Bottom"> |
| <PagerStyle Mode="NextPrevAndNumeric" /> |
| <Columns> |
| <telerik:GridEditCommandColumn ButtonType="ImageButton" /> |
| <telerik:gridboundcolumn headertext="Last Name" datafield="lastname" /> |
| <telerik:gridboundcolumn headertext="First Name" datafield="firstname" /> |
| <telerik:gridboundcolumn headertext="Phone #" datafield="Telephone"/> |
| <telerik:gridboundcolumn headertext="Email" datafield="email" /> |
| <telerik:GridButtonColumn headertext="Lock" CommandName="Lock" ButtonType="ImageButton" |
| ...etc. |
| </Columns> |
| <EditFormSettings EditFormType="Template"> |
| <FormTemplate> |
| <table cellspacing="7" cellpadding="1" width="100%"> |
| <tr><td colspan="2"><b>Username: <span id="spanUname" runat="server"><%# Eval("username") %></span></b> |
| <asp:TextBox Width="200px" ID="tbUname" runat="server"/></td></tr> |
| <tr><td><table class="update"><tr> |
| ...etc |
Form works perfectly.
When I try to get values on update as shown in the example http://www.telerik.com/help/aspnet-ajax/grdupdatingvaluesusercontrolformtemplate.html:
| switch (e.CommandName) |
| { |
| case RadGrid.InitInsertCommandName: |
| GridEditableItem editedItem = e.Item as GridEditableItem; |
| string s = (editedItem.FindControl("tbUname") as TextBox).Text; |
| ...etc. |
It gives me NullReferenceException, because editedItem is null. When I try to debug, there are absolutely no Controls for e.Item.
I am confused how I can get values from my Textboxes in FormTemplate.
Elena