Hi
I am trying to push the go button in the edit mode and get a reference to the label lb1 but then get an error:
Unable to cast object of type 'Telerik.Web.UI.GridDataItem' to type 'Telerik.Web.UI.GridEditFormItem'
this is the code:
any suggestions?
thanks
D
I am trying to push the go button in the edit mode and get a reference to the label lb1 but then get an error:
Unable to cast object of type 'Telerik.Web.UI.GridDataItem' to type 'Telerik.Web.UI.GridEditFormItem'
this is the code:
| <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Itemcommand.aspx.vb" Inherits="Itemcommand" %> |
| <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head runat="server"> |
| <title></title> |
| </head> |
| <body> |
| <form id="form1" runat="server"> |
| <div> |
| <telerik:RadScriptManager runat="server"> |
| </telerik:RadScriptManager> |
| <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" |
| AutoGenerateColumns="False" |
| ShowStatusBar="True" DataSourceID="SqlDataSource1"> |
| <MasterTableView CommandItemDisplay="TopAndBottom" GridLines="None" DataKeyNames="EmployeeID" |
| AllowFilteringByColumn="False" AllowSorting="True" DataSourceID="SqlDataSource1"> |
| <Columns> |
| <telerik:GridEditCommandColumn UniqueName="EditCommandColumn"> |
| </telerik:GridEditCommandColumn> |
| <telerik:GridBoundColumn UniqueName="EmployeeID" HeaderText="EmployeeID" DataField="EmployeeID" |
| DataType="System.Int32" ReadOnly="True" SortExpression="EmployeeID"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="City" HeaderText="City" SortExpression="City" |
| UniqueName="City"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="Country" HeaderText="Country" SortExpression="Country" |
| UniqueName="Country"> |
| </telerik:GridBoundColumn> |
| </Columns> |
| <EditFormSettings EditFormType="Template"> |
| <EditColumn UniqueName="EditCommandColumn1"> |
| </EditColumn> |
| <FormTemplate> |
| <table id="Table3" cellspacing="1" cellpadding="1" width="250" border="0" class="module"> |
| <tr> |
| <td> |
| </td> |
| <td> |
| </td> |
| </tr> |
| <tr> |
| <td> |
| Country: |
| </td> |
| <td> |
| <asp:TextBox ID="TextBox7" runat="server" Text='<%# Bind( "Country" ) %>'> |
| </asp:TextBox> |
| </td> |
| </tr> |
| <tr> |
| <td> |
| City: |
| </td> |
| <td> |
| <asp:TextBox ID="TextBox8" runat="server" Text='<%# Bind( "City") %>' TabIndex="1"> |
| </asp:TextBox> |
| </td> |
| </tr> |
| <tr> |
| <td> |
| <asp:Button ID="btnTest" CommandName="test" text="go" runat="server" /> |
| <asp:Label ID="lb1" runat="server"></asp:Label> |
| </td> |
| </tr> |
| </table> |
| </table> |
| </FormTemplate> |
| </EditFormSettings> |
| </MasterTableView> |
| </telerik:RadGrid> |
| </div> |
| <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:nwindConnectionString %>" |
| ProviderName="<%$ ConnectionStrings:nwindConnectionString.ProviderName %>" SelectCommand="SELECT * FROM [Employees]"> |
| </asp:SqlDataSource> |
| </form> |
| </body> |
| </html> |
| Imports Telerik.Web.UI |
| Partial Class Itemcommand |
| Inherits System.Web.UI.Page |
| Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand |
| If e.CommandName = "test" Then |
| Dim edititem As GridEditFormItem = CType(e.Item, GridEditFormItem) |
| 'get reference to label lb1 |
| Dim str As Label = edititem.FindControl("lb1") |
| str.Text = "hallo" |
| End If |
| End Sub |
| End Class |
any suggestions?
thanks
D