Hi
I have build a grid with a formtemplate. I want to set the label text through a button click. The problem is that it cant find the reference to the label. What to do?
reg
D
I have build a grid with a formtemplate. I want to set the label text through a button click. The problem is that it cant find the reference to the label. What to do?
reg
D
<%@ 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_ItemCreated1(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated |
If e.Item.ItemType = GridItemType.EditFormItem And e.Item.IsInEditMode Then |
Dim testbut As Button = CType(e.Item.FindControl("btnTest"), Button) |
Dim lbref As Label = CType(e.Item.FindControl("lb1"), Label) |
AddHandler testbut.Click, AddressOf testbutclicked |
End If |
End Sub |
Protected Sub testbutclicked(ByVal sender As Object, ByVal e As EventArgs) |
Dim lb As Label = RadGrid1.FindControl("lb1") |
lb.Text = "hi" |
End Sub |
End Class |