Hello,
I have the following CommandItemTemplate (below) in my RadGrid and I am wondering how to access the buttons and checkboxes in that template. Specifically, I want to disable/enable them when appropriate. How do I access those controls programatically serverside? I'll be doing this in the PageLoad() method. VB.NET. Thanks for the help!
<telerik:RadGrid ID="rgT" runat="server" Skin="WebBlue" AutoGenerateColumns="False"
GridLines="None" AllowFilteringByColumn="True" AllowMultiRowEdit="true" AllowMultiRowSelection="true"
OnItemDataBound="rgT_ItemDataBound" OnItemCommand="rgT_ItemCommand" Width="1093px"
Height="500px">
<MasterTableView CommandItemDisplay="Top" EditMode="InPlace">
<Columns>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="FIELD1" HeaderText="" UniqueName="FIELD1"
ReadOnly="True" Display="false">
</telerik:GridBoundColumn>
</Columns>
<
CommandItemTemplate>
<div id="DivUA" runat="server" style="padding-top: 5px; padding-bottom: 5px">
<table>
<tr>
<td>
<asp:Button runat="server" ID="btnUA" Text="Save" ToolTip="Save all changes you've made to the data"
Width="70px" CommandName="UpdateAll" CssClass="CommandButton" /></td>
<td style="padding-left:15px">
<asp:Button runat="server" ID="btnCGC" Text="Cancel Edits" ToolTip="Cancel all unsaved edits made to the data and reload the original data"
Width="100px" CommandName="CancelAll" CssClass="CommandButton" /></td>
<td align="right" style="padding-left:15px">
<asp:Button runat="server" ID="btnEditSelected" Text="Edit Selected" ToolTip="Place all selected grid rows into edit mode."
Width="100px" CommandName="EditSelected" CssClass="CommandButton" />
</td>
<td align="right" style="width: 120px">
<asp:CheckBox ID="cbToggleApproved" runat="server" Text="Hide Approved" CssClass="Normal"
OnCheckedChanged="hideAllApproved" AutoPostBack="True" /></td>
<td align="right" style="width: 100px">
<asp:CheckBox ID="cbApproveAll" runat="server" Text="Approve All" AutoPostBack="True"
OnCheckedChanged="approveAllCheckChanged" CssClass="Normal" /></td>
</tr>
</table>
</div>
</CommandItemTemplate>
<MasterTableView EditMode="PopUp" CommandItemDisplay="Top" DataKeyNames="AddressId"> <EditFormSettings UserControlName="~/AddressEdit.ascx" EditFormType="WebUserControl" InsertCaption="Add new Address" PopUpSettings-Width="800px" FormStyle-BackColor="AliceBlue" FormStyle-BorderWidth="5px" FormStyle-BorderColor="Turquoise" CaptionFormatString="Edit Address ID: {0}" CaptionDataField="AddressId"> <EditColumn UniqueName="EditCommandColumnAddr"/> </EditFormSettings><%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %><!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> <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" /></head><body> <form id="form1" runat="server"> <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> <Scripts> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" /> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" /> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" /> </Scripts> </telerik:RadScriptManager> <script type="text/javascript"> function onTabSelecting(sender, args) { if (args.get_tab().get_pageViewID()) { args.get_tab().set_postBack(false); } } </script> <telerik:RadAjaxLoadingPanel runat="server" ID="LoadingPanel1" Skin="MetroTouch"> </telerik:RadAjaxLoadingPanel> <telerik:RadAjaxManager runat="server" ID="RadAjaxManager1" EnablePageHeadUpdate="true"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadTabStrip1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadTabStrip1"></telerik:AjaxUpdatedControl> <telerik:AjaxUpdatedControl ControlID="RadMultiPage1" LoadingPanelID="LoadingPanel1"> </telerik:AjaxUpdatedControl> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="RadMultiPage1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadMultiPage1"></telerik:AjaxUpdatedControl> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <telerik:RadTabStrip ID="RadTabStrip1" runat="server" MultiPageID="RadMultiPage1" Skin="MetroTouch" Align="Justify" Orientation="VerticalLeft" OnTabClick="RadTabStrip1_TabClick" Width="1000" OnClientTabSelecting="onTabSelecting"> </telerik:RadTabStrip> <telerik:RadMultiPage ID="RadMultiPage1" runat="server" OnPageViewCreated="RadMultiPage1_PageViewCreated"> </telerik:RadMultiPage> <div> </div> </form></body></html><%@ Control Language="C#" AutoEventWireup="true" CodeFile="dynamicbuilder.ascx.cs" Inherits="dynamicbuilder" %><asp:Panel ID="Panel_Dec" runat="server" Visible="false"> <div style="padding-top: 10px;"> <div style="float: left; padding-left: 15px;"> <asp:Label runat="server" ID="Label_NumericStartingValue"></asp:Label> </div> <br /> <div style="padding-top: 10px;"> <div style="float: left; padding-left: 15px;"> <asp:Label runat="server" ID="Label_NumericEndingValue"></asp:Label> </div></asp:Panel><asp:Panel ID="Panel_NV" runat="server" Visible="false"> <asp:Label runat="server" ID="Label2" Text="nvarchar"></asp:Label></asp:Panel><asp:Panel ID="Panel_DT" runat="server" Visible="false"> <div style="padding-top: 10px;"> <div style="float: left; padding-left: 15px;"> <asp:Label runat="server" ID="Label_StartDate"></asp:Label> </div> <br /> <br /> <div style="float: left; padding-left: 15px;"> <asp:Label runat="server" ID="Label_EndDate"></asp:Label> </div> </div></asp:Panel><asp:Panel ID="Panel_SP" runat="server" Visible="false"> <asp:Label runat="server" ID="Label4" Text="Special"></asp:Label></asp:Panel>using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;public partial class dynamicbuilder : System.Web.UI.UserControl{ protected void Page_Load(object sender, EventArgs e) { HidePanels(); string casestatement = ((RSession.UserSession)Session["RSession"]).CurrentParameterDT.ToLower(); switch (casestatement) { case ("string"): if (SpecialFields.Contains(((RSession.UserSession)Session["RSession"]).CurrentParameterFName.ToLower())) { Process_Special(); } else { Process_NVarChar(); } break; case ("integer"): Process_Decimal(); break; case ("decimal"): Process_Decimal(); break; case ("datetime"): Process_DateTime(); break; } } protected void HidePanels() { string casestatement = ((RSession.UserSession)Session["RSession"]).CurrentParameterDT.ToLower(); switch (casestatement) { case ("string"): if (SpecialFields.Contains(((RSession.UserSession)Session["RSession"]).CurrentParameterFName.ToLower())) { Panel_NV.Visible = false; Panel_DT.Visible = false; Panel_Dec.Visible = false; Panel_SP.Visible = true; } else { Panel_NV.Visible = true; Panel_DT.Visible = false; Panel_Dec.Visible = false; Panel_SP.Visible = false; } break; case ("integer"): Panel_NV.Visible = false; Panel_DT.Visible = false; Panel_Dec.Visible = true; Panel_SP.Visible = false; break; case ("decimal"): Panel_NV.Visible = false; Panel_DT.Visible = false; Panel_Dec.Visible = true; Panel_SP.Visible = false; break; case ("datetime"): Panel_NV.Visible = false; Panel_DT.Visible = true; Panel_Dec.Visible = false; Panel_SP.Visible = false; break; } } protected void Process_NVarChar() { } protected void Process_DateTime() { Label_StartDate.Text = ((RSession.UserSession)Session["RSession"]).CurrentParameterFLH + ": Starting Date"; Label_EndDate.Text = ((RSession.UserSession)Session["RSession"]).CurrentParameterFLH + ": Ending Date"; } protected void Process_Decimal() { Label_NumericStartingValue.Text = ((RSession.UserSession)Session["RSession"]).CurrentParameterFLH + ": Starting Value"; Label_NumericEndingValue.Text = ((RSession.UserSession)Session["RSession"]).CurrentParameterFLH + ": Ending Value"; } protected void Process_Special() { } protected string[] SpecialFields = { "mn", "ve" };}using System;using System.Collections.Generic;using System.Linq;using System.Web;public static class RSession{ public class UserSession { public string CurrentParameterTName { get; set; } public string CurrentParameterFName { get; set; } public string CurrentParameterFLH { get; set; } public string CurrentParameterDT { get; set; } }}