Hi,
I can't get the data on my EditForm, please help.
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
RadGrid1.MasterTableView.IsItemInserted = true;//so I can insert after load
RadGrid1.Rebind();
}
}
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.PerformInsertCommandName)
{
GridEditFormInsertItem f = (GridEditFormInsertItem)RadGrid1.MasterTableView.GetInsertItem();
Person p = new Person();
p.FirstName = (f.FindControl("FirstName") as TextBox).Text; //?? this control doesn't exist
}
}
protected void RadGrid1_InsertCommand(object sender, GridCommandEventArgs e)
{
GridEditFormInsertItem item = e.Item as GridEditFormInsertItem; //?? this is null
}
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
RadGrid1.DataSource = Conselors;//loads a List<Person>
}
<telerik:RadGrid ID="RadGrid1" runat="server"
AllowPaging="false" AllowSorting="false" AutoGenerateColumns="false"
AllowAutomaticDeletes="false" AllowAutomaticInserts="false" AllowAutomaticUpdates="false"
ShowHeader="false"
OnItemCommand="RadGrid1_ItemCommand"
OnPreRender="RadGrid1_PreRender"
OnNeedDataSource="RadGrid1_NeedDataSource"
OnInsertCommand="RadGrid1_InsertCommand">
<MasterTableView DataKeyNames="PersonID" Width="50%" CommandItemDisplay="Bottom">
<CommandItemTemplate>
<telerik:RadButton ID="RadButtonInsert" runat="server" Text="Add" CommandName="PerformInsert">
<Icon PrimaryIconCssClass="rbAdd" PrimaryIconLeft="4" PrimaryIconTop="3"></Icon>
</telerik:RadButton>
</CommandItemTemplate>
<CommandItemSettings />
<NoRecordsTemplate></NoRecordsTemplate>
<EditFormSettings>
<PopUpSettings Modal="true" />
</EditFormSettings>
<Columns>
<telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
</telerik:GridEditCommandColumn>
<telerik:GridBoundColumn UniqueName="FirstName" HeaderText="FirstName" DataField="FirstName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="LastName" HeaderText="LastName" DataField="LastName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Telephone" HeaderText="Telephone" DataField="Telephone">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Email" HeaderText="Email" DataField="Email">
</telerik:GridBoundColumn>
<telerik:GridButtonColumn Text="Delete" CommandName="Delete" ButtonType="ImageButton" />
</Columns>
<EditFormSettings EditFormType="Template">
<FormTemplate>
* Person Name (Salutation, First, Middle, Last and Suffix):<br />
<telerik:RadComboBox ID="RadComboBox1" runat="server"
EnableLoadOnDemand="True" ShowMoreResultsBox="true" EnableVirtualScrolling="true"
OnItemsRequested="DropDownListCertHolderSalutation_ItemsRequested">
</telerik:RadComboBox>
<telerik:RadTextBox Width="250px" ID="TextBoxAttorneyFirstName" Text='<%# Bind( "FirstName") %>' runat="server" TabIndex="8">
</telerik:RadTextBox>
<telerik:RadTextBox Width="25px" ID="TextBoxAttorneyMiddleInitial" Text='<%# Bind( "MiddleInitial") %>' runat="server">
</telerik:RadTextBox>
<telerik:RadTextBox Width="250px" ID="TextBoxAttorneyLastName" Text='<%# Bind( "LastName") %>' runat="server">
</telerik:RadTextBox>
<telerik:RadComboBox ID="RadComboBox2" runat="server"
EnableLoadOnDemand="True" ShowMoreResultsBox="true" EnableVirtualScrolling="true"
OnItemsRequested="DropDownListCertHolderSuffix_ItemsRequested">
</telerik:RadComboBox>
<br />
Address:<br />
<telerik:RadTextBox Width="500px" ID="TextBoxAttorneyAddress1" Text='<%# Bind( "Address1") %>' runat="server">
</telerik:RadTextBox>
<br />
<telerik:RadTextBox Width="500px" ID="TextBoxAttorneyAddress2" Text='<%# Bind( "Address2") %>' runat="server">
</telerik:RadTextBox>
<br />
Country:
<telerik:RadComboBox ID="RadComboBox3" runat="server"
EnableLoadOnDemand="True" ShowMoreResultsBox="true" EnableVirtualScrolling="true" AutoPostBack="true"
OnItemsRequested="DropDownListCertHolderCountry_ItemsRequested"
OnSelectedIndexChanged="DropDownListCertHolderCountry_SelectedIndexChanged">
</telerik:RadComboBox>
  State:
<telerik:RadComboBox ID="RadComboBox4" runat="server"
EnableLoadOnDemand="True" ShowMoreResultsBox="true" EnableVirtualScrolling="true"
OnItemsRequested="DropDownListCertHolderState_ItemsRequested">
</telerik:RadComboBox>
<telerik:RadTextBox ID="RadTextBox6" runat="server" Width="200px" Visible="false"></telerik:RadTextBox>
  City:
<telerik:RadTextBox ID="RadTextBox7" runat="server" Width="250px"></telerik:RadTextBox>
  Zip Code:
<telerik:RadMaskedTextBox Width="50px" ID="RadMaskedTextBox1" runat="server" Mask="#####" TextMode="SingleLine">
</telerik:RadMaskedTextBox>
<br />
Telephone:
<telerik:RadMaskedTextBox Width="125px" ID="RadMaskedTextBox2" runat="server" Mask="(###) ###-####-####" TextMode="SingleLine">
</telerik:RadMaskedTextBox>
  Fax:
<telerik:RadMaskedTextBox Width="125px" ID="RadMaskedTextBox3" runat="server" Mask="(###) ###-####-####" TextMode="SingleLine">
</telerik:RadMaskedTextBox>
 
Email Address:
<telerik:RadTextBox ID="RadTextBox8" runat="server" Width="250px"></telerik:RadTextBox>
<br />
</FormTemplate>
</EditFormSettings>
</MasterTableView>
</telerik:RadGrid>
<telerik:RadComboBox ID="ddlLocation" runat="server" Width="125px" Font-Size="Small" AutoPostBack="false" onchanged="JavaScript: return DisableBox();">
</telerik:RadComboBox>
</td>
<td>
<telerik:RadTextBox ID="LocTextBox" runat="server" Width="100px" MaxLength="4" ToolTip="Please enter 4 char Location" AutoPostBack="false">
</telerik:RadTextBox>
</td>
function
DisableBox()
{
var TextBox = $find("<%=LocTextBox.ClientID %>");
var Location = $find("<%=ddlLocation.ClientID %>");
if(Location.length > 0)
{
TextBox.disable();
return false;
}
}
Please help to resolve this issue.
Thanks so much
class AssignBanGridCtrl : WebControl { #region Fields private RadAjaxLoadingPanel _RadLoadingPanel = new RadAjaxLoadingPanel(); private UpdatePanel _UpdatePanel = new UpdatePanel(); private RadGrid _RadGrid1 = new RadGrid(); private PriceDealProductBanTable _PriceDealProductBanTable = new PriceDealProductBanTable(); private PriceDealProposal _Proposal = null; private GXButton _btnCopyToSelect = new GXButton(); private GXButton _btnSaveSelected = new GXButton(); private GXTextBox _TbBAN = new GXTextBox(); public SmartOrderQuote OrderQuote; private string _BanColumnName; private string _ServiceColumnName; #endregion #region Constructors public AssignBanGridCtrl(PriceDealProposal proposal, bool hasOrderRequest) : base() { } #endregion #region Overrides protected override void OnInit(EventArgs e) { base.OnInit(e); this._ProductTable = new _ProductTable().ExecuteTypedDataTable(); this._RadLoadingPanel.ID = "_RadLoadingPanel"; this._RadLoadingPanel.Transparency = 30; this._RadLoadingPanel.Skin = "WebBlue"; this._RadLoadingPanel.BackgroundPosition = AjaxLoadingPanelBackgroundPosition.Center; this.Controls.Add(this._RadLoadingPanel); #region Grid1 this._RadGrid1.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = false; this._RadGrid1.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top; this._RadGrid.ID = "RadGrid1"; this._RadGrid.Skin = "WebBlue"; this._RadGrid.Width = Unit.Percentage(100); this._RadGrid.GridLines = GridLines.None; this._RadGrid.PageSize = 100; this._RadGrid.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric; this._RadGrid.AllowPaging = true; this._RadGrid.AutoGenerateColumns = false; this._RadGrid.EnableLinqExpressions = false; this._RadGrid.AllowAutomaticInserts = false; this._RadGrid.AllowAutomaticUpdates = false; this._RadGrid.AllowAutomaticDeletes = false; if(this._ProductTable.Count>=100) this._RadGrid1.AllowFilteringByColumn = true; this._RadGrid1.AllowSorting = true; this._RadGrid1.MasterTableView.AllowNaturalSort = false; this._RadGrid1.MasterTableView.DataKeyNames = new string[] { this._ProductTable.PriceDealEntityProductItemIdColumn.ColumnName }; this._RadGrid1.MasterTableView.ClientDataKeyNames = new string[] { this._ProductTable.PriceDealEntityProductItemIdColumn.ColumnName }; this._RadGrid1.EnableLinqExpressions = false; this._RadGrid1.MasterTableView.NoMasterRecordsText = "No Products found."; this._RadGrid1.MasterTableView.Width = Unit.Percentage(100); this._RadGrid1.ClientSettings.Selecting.AllowRowSelect = true; this._RadGrid1.ClientSettings.Selecting.UseClientSelectColumnOnly = true; this._RadGrid1.AllowMultiRowSelection = true; this._RadGrid1.NeedDataSource += RadGrid1_NeedDataSource; this._RadGrid1.ItemDataBound += RadGrid1_ItemDataBound; this._RadGrid1.ItemCreated += RadGrid1_ItemCreated; GridBoundColumn boundColumn = new GridBoundColumn(); string columnName; #region RadGrid Columns GridClientSelectColumn selectAll = new GridClientSelectColumn(); selectAll.UniqueName = "SelectOne"; this._RadGrid1.MasterTableView.Columns.Add(selectAll); string templateColumnName; GridTemplateColumn templateColumn = new GridTemplateColumn(); columnName = this._ProductTable.SupplementalOriginalPriceDealEntityProductItemIdColumn.ColumnName; ; boundColumn = new GridBoundColumn(); boundColumn.DataField = columnName; boundColumn.UniqueName = "SupplementalOriginalPriceDealEntityProductItemId"; boundColumn.Display = false; this._RadGrid1.MasterTableView.Columns.Add(boundColumn); columnName = this._ProductTable.IsCustomProductColumn.ColumnName; ; boundColumn = new GridBoundColumn(); boundColumn.DataField = columnName; boundColumn.UniqueName = "IsCustomProduct"; boundColumn.Display = false; this._RadGrid1.MasterTableView.Columns.Add(boundColumn); columnName = this._ProductTable.SupplementalActionCodeColumn.ColumnName; ; boundColumn = new GridBoundColumn(); boundColumn.DataField = columnName; boundColumn.UniqueName = "SupplementalActionCode"; boundColumn.Display = false; this._RadGrid1.MasterTableView.Columns.Add(boundColumn); columnName = this._ProductTable.IsLockedColumn.ColumnName; ; boundColumn = new GridBoundColumn(); boundColumn.DataField = columnName; boundColumn.UniqueName = "IsLocked"; boundColumn.Display = false; this._RadGrid1.MasterTableView.Columns.Add(boundColumn); columnName = this._ProductTable.DescriptionColumn.ColumnName; ; boundColumn = new GridBoundColumn(); boundColumn.DataField = columnName; boundColumn.HeaderText = "Location"; boundColumn.UniqueName = "Location"; boundColumn.SortExpression = columnName; this._RadGrid1.MasterTableView.Columns.Add(boundColumn); columnName = this._ProductTable.CatalogProductColumn.ColumnName; boundColumn = new GridBoundColumn(); boundColumn.FilterTemplate = new DropdownTemplate(columnName, _RadGrid1, this._ProductTable.SelectDistinct(columnName)); boundColumn.DataField = columnName; boundColumn.HeaderText = "Product"; boundColumn.UniqueName = "Product"; boundColumn.AllowFiltering = true; boundColumn.SortExpression = columnName; this._RadGrid1.MasterTableView.Columns.Add(boundColumn); columnName = this._ProductTable.CountryColumn.ColumnName; boundColumn = new GridBoundColumn(); boundColumn.FilterTemplate = new DropdownTemplate(columnName, _RadGrid1, this._ProductTable.SelectDistinct(columnName)); boundColumn.DataField = columnName; boundColumn.HeaderText = "Country"; boundColumn.UniqueName= "Country"; boundColumn.AllowFiltering = true; boundColumn.SortExpression = columnName; this._RadGrid1.MasterTableView.Columns.Add(boundColumn); columnName = this._ProductTable.StateColumn.ColumnName; boundColumn = new GridBoundColumn(); boundColumn.FilterTemplate = new DropdownTemplate(columnName, _RadGrid1, this._ProductTable.SelectDistinct(columnName)); boundColumn.DataField = columnName; boundColumn.HeaderText = "State/Province"; boundColumn.UniqueName = "StateProvince"; boundColumn.AllowFiltering = true; boundColumn.SortExpression = columnName; this._RadGrid1.MasterTableView.Columns.Add(boundColumn); columnName = this._ProductTable.SourceSystemTypeDescriptionColumn.ColumnName; boundColumn = new GridBoundColumn(); boundColumn.FilterTemplate = new DropdownTemplate(columnName, _RadGrid1, this._ProductTable.SelectDistinct(columnName)); boundColumn.DataField = columnName; boundColumn.HeaderText = "OE System"; boundColumn.UniqueName = "OESystem"; boundColumn.SortExpression = columnName; boundColumn.AllowFiltering = true; this._RadGrid1.MasterTableView.Columns.Add(boundColumn); templateColumn = new GridTemplateColumn(); _BanColumnName = this._ProductTable.BillingAccountNumberColumn.ColumnName; templateColumn.DataField = _BanColumnName; templateColumn.ItemTemplate = new TextBoxTemplate(_BanColumnName); templateColumn.HeaderText = "BAN"; templateColumn.UniqueName = "BAN"; templateColumn.AllowFiltering = false; this._RadGrid1.MasterTableView.Columns.Add(templateColumn); if (IsSupplementOrChangeQuote) { _ServiceColumnName = this._ProductTable.AssetServiceIdColumn.ColumnName; templateColumn = new GridTemplateColumn(); templateColumn.ItemTemplate = new TextBoxTemplate(_ServiceColumnName); templateColumn.DataField = _ServiceColumnName; templateColumn.HeaderText = "Asset/Service ID"; templateColumn.UniqueName = "AssetServiceID"; templateColumn.AllowFiltering = false; this._RadGrid1.MasterTableView.Columns.Add(templateColumn); } #endregion #endregion this._UpdatePanel.UpdateMode = UpdatePanelUpdateMode.Conditional; this._UpdatePanel.ContentTemplateContainer.Controls.Add(this._RadGrid1); this._TbBAN.ID = "TbBAN"; this._TbBAN.ShowTitle = true; this._TbBAN.MaxLength = 30; this._TbBAN.WikiKeyword = "Assignment"; this._TbBAN.Title = "BAN :"; this._UpdatePanel.ContentTemplateContainer.Controls.Add(this._TbBAN); this._btnCopyToSelect.ID = "BtCopyToSelected"; this._btnCopyToSelect.Text = "Copy To Selected"; this._btnCopyToSelect.ToolTip = "This will save the BAN above to all selected items."; this._btnCopyToSelect.CssClass = "GxButtonBlue"; this._btnCopyToSelect.Click += new EventHandler(BtnCopyToSelected_Click); this._UpdatePanel.ContentTemplateContainer.Controls.Add(this._btnCopyToSelect); this._btnSaveSelected.ID = "BtSaveToSelected"; this._btnSaveSelected.Text = "Save Selected"; this._btnSaveSelected.CssClass = "GxButtonBlue"; this._btnSaveSelected.Click += new EventHandler(BtSaveToSelected_Click); this._UpdatePanel.ContentTemplateContainer.Controls.Add(this._btnSaveSelected); this.Controls.Add(this._UpdatePanel); this._btnCopyToSelect.OnClientClick = "OnClientClick('" + _RadGrid1.ClientID + "')"; this._btnSaveSelected.OnClientClick = "OnClientClick('" + _RadGrid1.ClientID + "')"; } private void BtnCopyToSelected_Click(object sender, EventArgs e) { } void BtSaveToSelected_Click(object sender, EventArgs e) { } protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { } } protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { GridDataItem dataItem = (GridDataItem)e.Item; RadTextBox txtBan = (RadTextBox)dataItem.FindControl(_BanColumnName);// pass the TextBox ID txtBan.Attributes.Add("onfocus", "SelectRow('" + dataItem.ItemIndex + "','" + _RadGrid1.ClientID + "')"); } } #endregion void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { try { this._ProductTable = new _ProductTable().ExecuteTypedDataTable(); } catch (Exception) { } this._RadGrid1.DataSource = this._ProductTable; } protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); RadAjaxManager ajaxManager = RadAjaxManager.GetCurrent(Page); if (ajaxManager != null) ajaxManager.AjaxSettings.AddAjaxSetting(this._UpdatePanel, this._RadGrid1, this._RadLoadingPanel); } }}
RadGrid_Strategy.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top; RadGrid_Strategy.MasterTableView.EditMode = GridEditMode.Batch; RadGrid_Strategy.MasterTableView.BatchEditingSettings.EditType = GridBatchEditingType.Cell; RadGrid_Strategy.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = false; RadGrid_Strategy.MasterTableView.CommandItemSettings.ShowSaveChangesButton = true; RadGrid_Strategy.MasterTableView.CommandItemSettings.ShowCancelChangesButton = true;RadGrid1.AllowSorting = TrueadGrid1.MasterTableView.AllowSorting = TrueadGrid1.ClientSettings.Scrolling.UseStaticHeaders = TrueadGrid1.MasterTableView.PageSize = 30adGrid1.MasterTableView.AllowPaging = TrueadGrid1.AllowPaging = False <style type="text/css"> #RadGrid1Panel, .RadGrid, .RadGrid_Default{ width: 700px !important; } </style><telerik:RadGrid ID="RadGrid1" runat="server" MasterTableView-EnableHeaderContextMenu="true" Height="900px" Width="700px" > <ClientSettings> <Scrolling AllowScroll="True"></Scrolling> </ClientSettings> </telerik:RadGrid>Dim tableViewOrders = New GridTableView(RadGrid1)RadGrid1.MasterTableView.DetailTables.Add(tableViewOrders)