I am trying to retrieve value of the selected item in GridDropDownColumn on RadGrid1_UpdateCommand event. I get
Error: "Cannot find a cell bound to column name 'FormID'". I am giving all the code, but the issue is in RadGrid1_UpdateCommand when it tries to get the FormID.
<telerik:RadGrid ID="RadGrid1"runat="server"AutoGenerateColumns="False"GridLines="None"
AllowMultiRowEdit="True"OnItemDataBound="RadGrid1_ItemDataBound"OnNeedDataSource="RadGrid1_NeedDataSource"
OnUpdateCommand="RadGrid1_UpdateCommand">
<MasterTableViewAutoGenerateColumns="false"DataKeyNames="AccessID"Width="100%"
CommandItemDisplay="Top">
<Columns>
<telerik:GridButtonColumn CommandName="Delete"Text="Delete"UniqueName="Delete">
</telerik:GridButtonColumn>
<telerik:GridBoundColumn DataField="AccessID" DataType="System.Int32" FilterControlAltText="Filter AccessID column"
HeaderText="Access
ID" ReadOnly="True"SortExpression="AccessID" UniqueName="AccessID">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="FirstName"FilterControlAltText="Filter
FirstName column"
HeaderText="First
Name" ReadOnly="True" SortExpression="FirstName" UniqueName="FirstName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="LastName"FilterControlAltText="Filter
LastName column"
HeaderText="Last
Name" ReadOnly="True" SortExpression="LastName" UniqueName="LastName">
</telerik:GridBoundColumn>
<telerik:GridDropDownColumnFilterControlAltText="Filter
ddlForm column" UniqueName="ddlForm"
ListTextField="FormName"ListValueField="FormID"SortExpression="FormName"
HeaderText="Form
Name"
DataField="FormID"ListDataMember="FormName"DropDownControlType="DropDownList">
</telerik:GridDropDownColumn>
<telerik:GridBoundColumn DataField="ContactType"FilterControlAltText="Filter
ContactType column"
HeaderText="Contact
Type" SortExpression="ContactType" UniqueName="ContactType">
</telerik:GridBoundColumn>
<telerik:GridEditCommandColumn>
</telerik:GridEditCommandColumn>
</Columns>
<EditFormSettingsColumnNumber="2"CaptionFormatString="Edit
details for Access ID {0}"
CaptionDataField="AccessID">
<FormTableItemStyle Wrap="False"></FormTableItemStyle>
<FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
<FormMainTableStyle CellSpacing="0"CellPadding="3"Width="100%"/>
<FormTableStyle GridLines="Horizontal"CellSpacing="0"CellPadding="2"CssClass="module"
Height="110px"Width="100%"/>
<FormTableAlternatingItemStyleWrap="False"></FormTableAlternatingItemStyle>
<FormStyle Width="100%"BackColor="#EEF2EA"></FormStyle>
<EditColumn UpdateText="Update
record" UniqueName="EditCommandColumn1" CancelText="Cancel
edit">
</EditColumn>
<FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>
</EditFormSettings>
</MasterTableView>
</telerik:RadGrid>
Here is code behine:
protected void RadGrid1_NeedDataSource(object source,
Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
SqlConnection con = newSqlConnection(DataAccess.Connection.StrConn);
SqlCommand cmd = newSqlCommand("dbo.MyStoredProc",
con);
SqlDataAdapter adapter = newSqlDataAdapter();
adapter.SelectCommand = cmd;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandTimeout = 90;
DataTable myDataTable = newDataTable();
con.Open();
try
{
adapter.Fill(myDataTable);
}
finally
{
con.Close();
}
RadGrid1.DataSource = myDataTable;
}
protected void RadGrid1_ItemDataBound(object sender,
Telerik.Web.UI.GridItemEventArgs e)
{
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
GridEditManager editMan =
editedItem.EditManager;
GridDropDownListColumnEditor editor =
editMan.GetColumnEditor("ddlForm") as GridDropDownListColumnEditor;
DropDownList ddList =
editor.DropDownListControl;
ddList.DataSource = GetDataTable("SELECT
FormID, FormName FROM dbo.[Table_FormList]"); //ds;
ddList.DataTextField = "FormName";
ddList.DataValueField = "FormID";
ddList.DataBind();
}
}
public DataTable GetDataTable(string query)
{
SqlConnection con = new SqlConnection(DataAccess.Connection.StrConn);
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = new SqlCommand(query, con);
DataTable myDataTable = new DataTable();
con.Open();
try
{
adapter.Fill(myDataTable);
}
finally
{
con.Close();
}
return myDataTable;
}
protected void RadGrid1_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
{
if (e.Item isGridEditableItem &&
e.Item.IsInEditMode)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
string AccessID =
editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["AccessID"].ToString();
//error on this line
string FormID = (editedItem["FormID"].Controls[0] as DropDownList).SelectedItem.Text;
string ContactType = (editedItem["ContactType"].Controls[0] as TextBox).Text;
try
{
//do update to database
}
catch (Exception ex)
{
RadGrid1.Controls.Add(new LiteralControl("Unable to update data. Reason: " +
ex.Message));
e.Canceled = true;
}
}
}
I have a Pivot grid with two filter. I am able to save and load the saved filter settings from the xml file in App_Data. But now I need some modifications to be made.
One of the Filters is a DataRange field which holds the Release dates and I want the Latest DateRange to be selected by default on load. Since this will require the saved xml file to be updated with new values.
I will have the latest Date in my dataset. is there a way to update the saved xml file with a value from the Dataset before loading the pivot with default settings.
I am using a RadGrid, on load some of the columns are hidden. I have a button which should unhide those columns when clicked and the text should change to Hide. On click of the same button again the columns should hide. I am able to hide the columns successfully but unable to figure out how to unhide.
Here is the code:
<input type="button" id ="toggle" value = "Hide" onclick="HideUnhide()" class="=tdText" /></>
function HideUnhide() {
var grid = $find("<%= RadGrid1.ClientID %>");
grid.get_masterTableView().hideColumn(8);
grid.get_masterTableView().hideColumn(9);
grid.get_masterTableView().hideColumn(10);
}
I am trying to include condition in the function where I can change the text from Unhide to Hide and depending on the text Unhide the columns in the else part but that doesn't seem to work.
Currently this code can only hide unhidden columns.
Please help.
I have several grids that won't transfer tool tips and other column "decorations" like left / right justification when a column is moved interactively by the user. I believe I have found via google search this was a know problem in older versions. Is there a way I can tell which versions have the problem?
We are running 2014.3
In my current program I have 2 RadComboBoxes within col-md-4 divs.
The labels of these boxes are vertically out of line both with their drop down boxes and with the RadTextBox on the same line (in another col-md-4 div).
Is there a way yet to fix this, either through settings or CSS?
Most of the references I've found so far seem pretty old. (I'm currently running the latest version of the Telerik Asp.Net for Ajax controls.)
<telerik:RadMediaPlayer ID="RadMediaPlayer2" runat="server" Width="500" Height="400px" Source="~/Videos/RadControls.mp4"></telerik:RadMediaPlayer><telerik:RadMediaPlayer ID="RadMediaPlayer1" runat="server" Width="500" Height="400px"> <Sources> <telerik:MediaPlayerSource Path="~/Videos/RadControls.mp4" /> </Sources></telerik:RadMediaPlayer>Hello,
Can exist dynamically generated RadGrid with static RadGrid on the same aspx webform page?
The situation:
I have put two radgrids on the same page (one is created in Page_Init() another static). Every thing worked fine until I decided to add GridTemplateColumn to dynamically created grid (using IBindableTemplate and ITemplate). Then I started to get error:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Stack empty.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: Stack empty.]
System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) +52
System.Collections.Generic.Stack`1.Pop() +6856361
Microsoft.VisualStudio.Web.PageInspector.Runtime.WebForms.SelectionMappingRenderTraceListener.EndRendering(TextWriter writer, Object renderedObject) +84
System.Web.UI.RenderTraceListenerList.EndRendering(TextWriter writer, Object renderedObject) +66
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +170
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1303
I get this error when I try to edit or add new record on static RadGrid.
The dynamically created RadGrid works without problem.
I have even created new empty project to test this and the problem remains.
Any Ideas?
Thanks
Darius
Using Telerik 2017.1.118.45 version.
Having the following setup of my RadGrid:
<telerik:RadGrid runat="server" ID="gvResults" AllowMultiRowSelection="True" AlternatingItemStyle-BackColor="White" PageSize="10" AllowPaging="True" Skin="Bootstrap" AutoGenerateColumns="False" AllowSorting="True" OnNeedDataSource="gvResults_NeedDataSource" GroupPanelPosition="Top" OnItemCommand="gvResults_ItemCommand" OnItemCreated="gvResults_ItemCreated"> <ClientSettings EnableRowHoverStyle="true" EnableAlternatingItems="false" EnablePostBackOnRowClick="true"> <Selecting AllowRowSelect="true" /> <%--<ClientEvents OnRowSelected="onRowSelected" OnRowDeselected="onRowDeselected" />--%> </ClientSettings> <AlternatingItemStyle BackColor="White" /> <MasterTableView DataKeyNames="Id"> <NestedViewTemplate> <div style="margin: 10px;"> <div class="row"> <div class="col-md-6"> <div> <h4> <%# Eval("OrderCode") %> </h4> </div> <luc:SilencerDetailsView runat="server" ID="silencerDetailsView" /> <telerik:RadAjaxPanel runat="server" ID="apButtonAction"> <div class="btn-group"> <asp:Button runat="server" ID="btnGenPDF" Text="<%$ Resources:Resource, ButtonGeneratePDF %>" CssClass="btn btn-default" OnClick="btnOpenPDFDialog" /> <asp:Button runat="server" ID="btnGenDXF" Text="<%$ Resources:Resource, ButtonGenerateDXF %>" CssClass="btn btn-default" OnClick="btnGenDXF_Click" /> <asp:Button runat="server" ID="btnShowAddDialog" Text="<%$ Resources:Resource, LabelAddToProject %>" CssClass="btn btn-default" OnClick="btnShowAddDialog_Click" /> <asp:Button runat="server" ID="btnExportToMagiCAD" Text="<%$ Resources:Resource, LabelExportToMagiCAD %>" CssClass="btn btn-default" OnClick="btnExportToMC_Click" /> <asp:Button runat="server" ID="btnExportToRevit" Text="<%$ Resources:Resource, LabelExportToRevit %>" CssClass="btn btn-default" OnClick="btnExportToRvt_Click" /> </div> <asp:Panel runat="server" ID="pnlActionNotification" Style="margin-top: 5px;" Visible="false"></asp:Panel> </telerik:RadAjaxPanel> </div> <div class="col-md-6"> <luc:ProductDataView runat="server" ID="prodDataView" SelectedIndex="2" /> </div> </div> </div> </NestedViewTemplate> <Columns> <telerik:GridBoundColumn DataField="Id" FilterControlAltText="Filter column6 column" UniqueName="colId" Visible="False"> </telerik:GridBoundColumn> <telerik:GridClientSelectColumn UniqueName="checkColumn"> <HeaderStyle Width="42px" /> </telerik:GridClientSelectColumn> <telerik:GridImageColumn DataImageUrlFields="ImageThumbUrl" FilterControlAltText="Filter column column" HeaderText="" ItemStyle-HorizontalAlign="Center" ImageAlign="Middle" ImageHeight="40" ImageWidth="40" UniqueName="column"> <HeaderStyle Width="60px" /> </telerik:GridImageColumn> <telerik:GridButtonColumn ButtonType="LinkButton" DataTextField="OrderCode" HeaderText="<%$ Resources:Resource, LabelUserCode %>" UniqueName="colConfigure" CommandName="CONFIGURE"></telerik:GridButtonColumn> <telerik:GridHyperLinkColumn DataNavigateUrlFormatString="../calculator?source=search&id={0}" DataNavigateUrlFields="Id" AllowSorting="false" DataTextField="OrderCode" HeaderText="Ordercode" UniqueName="colOrderCode" Visible="false"> </telerik:GridHyperLinkColumn> <telerik:GridBoundColumn AllowSorting="true" SortExpression="ViewModel.Width" DataField="ViewModel.Width" FilterControlAltText="Filter column4 column" UniqueName="colWidth"> </telerik:GridBoundColumn> <telerik:GridBoundColumn AllowSorting="true" SortExpression="ViewModel.Height" DataField="ViewModel.Height" FilterControlAltText="Filter column4 column" UniqueName="colHeight"> </telerik:GridBoundColumn> <telerik:GridBoundColumn AllowSorting="true" SortExpression="ViewModel.Length" DataField="ViewModel.Length" FilterControlAltText="Filter column4 column" UniqueName="colLength"> </telerik:GridBoundColumn> <telerik:GridBoundColumn AllowSorting="true" SortExpression="NumberOfBaffles" DataField="NumberOfBaffles" FilterControlAltText="Filter column4 column" UniqueName="colNbrBaffles"> </telerik:GridBoundColumn> <telerik:GridNumericColumn AllowSorting="true" DataField="PriceFactor" Visible="false" FilterControlAltText="Filter column3 column" SortExpression="PriceFactor" UniqueName="colPrice"> </telerik:GridNumericColumn> <telerik:GridNumericColumn DataField="ViewModel.PressureLoss" FilterControlAltText="Filter column2 column" SortExpression="ViewModel.PressureLoss" UniqueName="colPressureLoss"> </telerik:GridNumericColumn> <telerik:GridNumericColumn DataField="SoundPower.Value" AllowSorting="true" SortExpression="SoundPower.Value" FilterControlAltText="Filter column5 column" HeaderText="Sound power [dB(A)]" UniqueName="colSoundPower"> </telerik:GridNumericColumn> <telerik:GridNumericColumn DataField="ViewModel.FaceVelocity" FilterControlAltText="Filter column3 column" UniqueName="colVelocity"> </telerik:GridNumericColumn> <telerik:GridButtonColumn Visible="false" ButtonType="PushButton" ButtonCssClass="btn btn-primary" Text="Quick Configure" CommandName="QUICK_CONFIGURE"></telerik:GridButtonColumn> </Columns> </MasterTableView> </telerik:RadGrid>
When list goes over 10 and tries to create pages it crashes with error:
Unhandled exception at line 6, column 18774 in http://localhost:50241/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=RadScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=;;System.Web.Extensions,+Version=4.0.0.0,+Culture=neutral,+PublicKeyToken=31bf3856ad364e35:en:4bd8faf8-554d-46be-b2ff-c9d57adb612c:ea597d4b:b25378d2;Telerik.Web.UI:en:e5f799c1-ae8d-47dd-a4eb-e98a7cefaaeb:16e4e7cd:f7645509:22a6274a:ed16cbdc:24ee1bba:33715776:6d43f6d9:88144a7a:583660290x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'toUpperCase'Type.prototype.registerEnum=function(b,c){Sys.__upperCaseTypes[b.toUpperCase()]=this;
Unhandled exception at line 6, column 54851 in http://localhost:50241/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=RadScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=;;System.Web.Extensions,+Version=4.0.0.0,+Culture=neutral,+PublicKeyToken=31bf3856ad364e35:en:4bd8faf8-554d-46be-b2ff-c9d57adb612c:ea597d4b:b25378d2;Telerik.Web.UI:en:e5f799c1-ae8d-47dd-a4eb-e98a7cefaaeb:16e4e7cd:f7645509:22a6274a:ed16cbdc:24ee1bba:33715776:6d43f6d9:88144a7a:58366029
0x800a01bd - JavaScript runtime error: Object doesn't support this action
var $create=Sys.Component.create=function(h,f,d,c,g){var a=g?new h(g):new h,b=Sys.Application,i=b.get_isCreatingComponents();a.beginUpdate();