We are using RadGrid (2008.2.1001) and are having quite a bit of difficulty getting a form template to work within the grid.
We tried both the form template and user control method, but apparently the user control method doesn't work with a LinqDataSource.
We also found that even when we used the NeedDataSource event to ensure data was continuously available, the grid would disappear if we attempted to sort for instance (or even pressed a command button within a form template.)
So we ended up adding a LinqDataSource and at least the grid stopped disappearing.
We've checked the forums, we've looked at the code, but we are a bit stumped. It seems that the Insert/Upate commands are not being fired. We click the buttons and the grid form simply closes. Using trace commands or even debugging seems like the commands aren't being fired for some reason.
We tried using a SqlDataSource just in case it may be the LinqDataSource but the results were the same.
It may be worth noting that the grid is in a user control in our case, which is in an Aspx page that utilizes a master page if that makes any difference. The ScriptManager is on the Aspx page.
Here is the applicable section of our ASCX page:
| <div class="form"> |
| <div class="innerForm"> |
| <p>This optional tab allows you to add a list of rooms or room types and specify the rates and conditions for each.</p> |
| <asp:ValidationSummary ID="ValidationSummary1" ValidationGroup="Config" runat="server" HeaderText="<strong>Form Errors:</strong>" DisplayMode="List" /><asp:Literal ID="FormMessage" runat="server" /> |
| <telerik:RadGrid ID="RadGrid1" Skin="Hay" AllowFilteringByColumn="false" ShowStatusBar="true" |
| AllowPaging="true" AllowSorting="true" runat="server" AutoGenerateColumns="false" |
| DataSourceID="SqlDataSource1" AllowAutomaticDeletes="true" AllowAutomaticInserts="true" |
| AllowAutomaticUpdates="true" OnItemCommand="RadGrid1_ItemCommand" |
| OnItemInserted="RadGrid1_ItemInserted" OnItemUpdated="RadGrid1_ItemUpdated" |
| oninsertcommand="RadGrid1_InsertCommand"> |
| <PagerStyle Mode="NextPrevAndNumeric" /> |
| <MasterTableView CommandItemDisplay="Top" DataSourceID="SqlDataSource1" DataKeyNames="RoomRateId"> |
| <Columns> |
| <telerik:GridEditCommandColumn ButtonType="LinkButton" EditText="Edit" UniqueName="EditCommandColumn1" /> |
| <telerik:GridBoundColumn DataField="RoomName" HeaderText="Room Name" |
| SortExpression="RoomName" UniqueName="RoomName"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="Rate1Persons" HeaderText="Persons" UniqueName="Rate1Persons" |
| SortExpression="Rate1Persons"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="Rate1Amount" HeaderText="Rate1 Amount" UniqueName="Rate1Amount" |
| SortExpression="Rate1Amount"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="Rate2Amount" HeaderText="Rate2 Amount" UniqueName="Rate2Amount" |
| SortExpression="Rate2Amount"> |
| </telerik:GridBoundColumn> |
| <telerik:GridCheckBoxColumn DataField="Active" HeaderText="Active" UniqueName="Active" SortExpression="Active"> |
| </telerik:GridCheckBoxColumn> |
| <telerik:GridCheckBoxColumn DataField="SelectedOffer" HeaderText="Selected" UniqueName="SelectedOffer" |
| SortExpression="SelectedOffer"> |
| </telerik:GridCheckBoxColumn> |
| <telerik:GridButtonColumn UniqueName="DeleteColumn" Text="Delete" CommandName="Delete" /> |
| </Columns> |
| <EditFormSettings EditFormType="Template"> |
| <FormTemplate> |
| <p><label class="req" style="width:93px; margin-left:5px;"><asp:Literal ID="litRoomNameLabel" runat="server" Text="Room Name:" EnableViewState="true" /></label><small class="note">Ex: Standard (non-smoking)</small> |
| <asp:TextBox ID="txtRoomName" Text='<%# Bind( "RoomName" ) %>' CssClass="input-text" runat="server" MaxLength="50"></asp:TextBox></p> |
| <p><label style="width:93px; margin-left:5px;"><asp:Literal ID="Literal1" runat="server" Text="Description:" EnableViewState="true" /></label><small class="note">Ex: Standard (non-smoking)</small> |
| <asp:TextBox ID="txtDescription" Text='<%# Bind( "Description" ) %>' CssClass="input-text" runat="server" MaxLength="50"></asp:TextBox></p> |
| <p><label style="width:93px; margin-left:5px;" class="req"><asp:Literal ID="Literal2" runat="server" Text="Persons:" EnableViewState="true" /></label> |
| <asp:TextBox ID="txtRate1Persons" Text='<%# Bind( "Rate1Persons" ) %>' CssClass="input-text" runat="server" MaxLength="50"></asp:TextBox></p> |
| <p><label style="width:93px; margin-left:5px;" class="req"><asp:Literal ID="litRate1AmountLabel" runat="server" Text="Rate1Amount:" EnableViewState="true" /></label><small class="note">Ex: 79.95</small> |
| <asp:TextBox ID="txtRate1Amount" Text='<%# Bind( "Rate1Amount" ) %>' CssClass="input-text" runat="server" MaxLength="50"></asp:TextBox></p> |
| <p><label style="width:93px; margin-left:5px;"><asp:Literal ID="litRate2AmountLabel" runat="server" Text="Rate2Amount:" EnableViewState="true" /></label><small class="note">Ex: 79.95</small> |
| <asp:TextBox ID="txtRate2Amount" Text='<%# Bind( "Rate2Amount" ) %>' CssClass="input-text" runat="server" MaxLength="50"></asp:TextBox></p> |
| <p><label style="width:93px; margin-left:5px;"><asp:Literal ID="litReservationURL" runat="server" Text="ReservationURL:" EnableViewState="true" /></label><small class="note">Ex: http://myhotel.com</small> |
| <asp:TextBox ID="txtReservationURL" Text='<%# Bind( "ReservationURL" ) %>' CssClass="input-text" runat="server" MaxLength="50"></asp:TextBox></p> |
| <p><label style="width:93px; margin-left:5px;">Selected:</label> |
| <asp:CheckBox ID="chkIsSelected" Checked='<%# Bind( "SelectedOffer" ) %>' CssClass="input-text" runat="server"></asp:CheckBox></p> |
| <p><label style="width:93px; margin-left:5px;">Activate:</label> |
| <asp:CheckBox ID="chkIsActive" Checked='<%# Bind( "Active" ) %>' CssClass="input-text" runat="server"></asp:CheckBox></p> |
| <div class="buttons"> |
| <asp:ImageButton id="btnCancel" CssClass="input-button" style="margin-right:10px" ImageUrl="~/images/btn-admin-cancel.gif" text="Cancel" runat="server" causesvalidation="false" commandname="Cancel"></asp:ImageButton> |
| <asp:ImageButton id="btnUpdate" CssClass="input-button" |
| style="margin-right:10px" ImageUrl="~/images/btn-admin-update.gif" |
| text="Update" ValidationGroup="AddEditFormGroup" runat="server" |
| CommandName="Update" |
| Visible='<%# !(Container is GridEditFormInsertItem) %>'></asp:ImageButton> |
| <asp:ImageButton id="btnInsert" CssClass="input-button" style="margin-right:10px" ImageUrl="~/images/btn-admin-submit.gif" text="Insert" ValidationGroup="AddEditFormGroup" runat="server" CommandName="PerformInsert" Visible='<%# (Container is GridEditFormInsertItem) %>'></asp:ImageButton> |
| </div> |
| </FormTemplate> |
| </EditFormSettings> |
| </MasterTableView> |
| </telerik:RadGrid> |
| </div> |
| </div> |
| <asp:LinqDataSource ID="LinqData" runat="server" EnableDelete="true" |
| EnableInsert="true" EnableUpdate="true" |
| ContextTypeName="contextinfowashere" |
| TableName="RoomRates" /> |
| <asp:SqlDataSource ID="SqlDataSource1" runat="server" |
| ConnectionString="Data Source=connectionstringwashere" |
| DeleteCommand="DELETE FROM [RoomRate] WHERE [RoomRateId] = @RoomRateId" |
| InsertCommand="INSERT INTO [RoomRate] ([RoomName], [Description], [Rate1Persons], [Rate1Amount], [Rate2Persons], [Rate2Amount], [ReservationURL], [SelectedOffer], [Active], [ListingId], [Version]) VALUES (@RoomName, @Description, @Rate1Persons, @Rate1Amount, @Rate2Persons, @Rate2Amount, @ReservationURL, @SelectedOffer, @Active, @ListingId, @Version)" |
| ProviderName="System.Data.SqlClient" |
| SelectCommand="SELECT * FROM [RoomRate] WHERE ([ListingId] = @ListingId)" |
| UpdateCommand="UPDATE [RoomRate] SET [RoomName] = @RoomName, [Description] = @Description, [Rate1Persons] = @Rate1Persons, [Rate1Amount] = @Rate1Amount, [Rate2Persons] = @Rate2Persons, [Rate2Amount] = @Rate2Amount, [ReservationURL] = @ReservationURL, [SelectedOffer] = @SelectedOffer, [Active] = @Active, [ListingId] = @ListingId, [Version] = @Version WHERE [RoomRateId] = @RoomRateId"> |
| <SelectParameters> |
| <asp:QueryStringParameter Name="ListingId" QueryStringField="id" Type="Int32" /> |
| </SelectParameters> |
| <DeleteParameters> |
| <asp:Parameter Name="RoomRateId" Type="Int32" /> |
| </DeleteParameters> |
| <UpdateParameters> |
| <asp:Parameter Name="RoomName" Type="String" /> |
| <asp:Parameter Name="Description" Type="String" /> |
| <asp:Parameter Name="Rate1Persons" Type="String" /> |
| <asp:Parameter Name="Rate1Amount" Type="Decimal" /> |
| <asp:Parameter Name="Rate2Persons" Type="String" /> |
| <asp:Parameter Name="Rate2Amount" Type="Decimal" /> |
| <asp:Parameter Name="ReservationURL" Type="String" /> |
| <asp:Parameter Name="SelectedOffer" Type="Boolean" /> |
| <asp:Parameter Name="Active" Type="Boolean" /> |
| <asp:Parameter Name="ListingId" Type="Int32" /> |
| <asp:Parameter Name="Version" Type="Object" /> |
| <asp:Parameter Name="RoomRateId" Type="Int32" /> |
| </UpdateParameters> |
| <InsertParameters> |
| <asp:Parameter Name="RoomName" Type="String" /> |
| <asp:Parameter Name="Description" Type="String" /> |
| <asp:Parameter Name="Rate1Persons" Type="String" /> |
| <asp:Parameter Name="Rate1Amount" Type="Decimal" /> |
| <asp:Parameter Name="Rate2Persons" Type="String" /> |
| <asp:Parameter Name="Rate2Amount" Type="Decimal" /> |
| <asp:Parameter Name="ReservationURL" Type="String" /> |
| <asp:Parameter Name="SelectedOffer" Type="Boolean" /> |
| <asp:Parameter Name="Active" Type="Boolean" /> |
| <asp:Parameter Name="ListingId" Type="Int32" /> |
| <asp:Parameter Name="Version" Type="Object" /> |
| </InsertParameters> |
| </asp:SqlDataSource> |
| protected void RadGrid1_ItemUpdated(object source, Telerik.Web.UI.GridUpdatedEventArgs e) |
| { |
| if (e.Exception != null) |
| { |
| e.KeepInEditMode = true; |
| e.ExceptionHandled = true; |
| AddMessage("RoomRate " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["RoomRateId"] + " cannot be updated. Reason: " + e.Exception.Message, FormMessage); |
| } |
| else |
| { |
| AddMessage("RoomRate " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["RoomRateId"] + " updated", FormMessage, false); |
| } |
| } |
| protected void RadGrid1_ItemInserted(object source, GridInsertedEventArgs e) |
| { |
| Trace.Warn("ItemInserted", "We made it!"); |
| if (e.Exception != null) |
| { |
| e.ExceptionHandled = true; |
| e.KeepInInsertMode = true; |
| AddMessage("Error: " + e.Exception.Message, FormMessage); |
| } |
| else |
| { |
| AddMessage("RoomRate " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["RoomRateId"] + " inserted", FormMessage, false); |
| } |
| } |
| protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) |
| { |
| if (e.CommandName == RadGrid.InitInsertCommandName) //"Add new" button clicked |
| { |
| Trace.Write("ItemCommand", "Add New button was clicked"); |
| e.Canceled = true; |
| //Prepare an IDictionary with the predefined values |
| System.Collections.Specialized.ListDictionary newValues = new System.Collections.Specialized.ListDictionary(); |
| //set default checked state for the checkbox inside the EditItemTemplate |
| newValues["SelectedOffer"] = false; |
| newValues["Active"] = true; |
| //Insert the item and rebind |
| e.Item.OwnerTableView.InsertItem(newValues); |
| } |
| else if (e.CommandName == RadGrid.RebindGridCommandName && e.Item.OwnerTableView.IsItemInserted) |
| { |
| e.Canceled = true; |
| } |
| else |
| { |
| Trace.Write("ItemCommand", "Edit button was clicked"); |
| } |
| } |
| protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e) |
| { |
| Trace.Write("InsertCommand", "Attempting to insert"); |
| } |
Hi,
For some reason i've suddenly got these Visual Studio 2005 errors:
Element 'csv' is not supported
Type 'Telerik.Web.UI.GridExportSettings' does not have a public property named 'CSV'.
when i build my project. It's been working fine for ages, and I can't see anything that has changed since the last good build.
It seems that the CSV exporting functionality has disappeared. What could have done this?
I usualy validate against XHTML 1.0 Transitional, but none of the others work either. I've re-registered the controls and relaunched VS.
This error seems to appear in all the .aspx files that use the grid. Also, intellisense doesn't see the <csv>, but it DOES see the <pdf> & <Excel>
Can anyone suggest what i can do?
My markup is:
...
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
...
<telerik:RadGrid ID="gridUsers" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" GridLines="None" OnPageIndexChanged="gridUsers_PageIndexChanged"
OnNeedDataSource="gridUsers_NeedDataSource">
<PagerStyle Mode="NextPrevAndNumeric" NextPageText="Next" PrevPageText="Prev" />
<ExportSettings>
<Pdf FontType="Subset" PaperSize="Letter" />
<Excel Format="Html" />
<Csv ColumnDelimiter="Comma" RowDelimiter="NewLine" /> <- FAILING HERE!!!
</ExportSettings>
<MasterTableView ClientDataKeyNames="Login" CommandItemDisplay="Top" CurrentResetPageIndexAction="SetPageIndexToFirst"
DataKeyNames="Login" Dir="LTR" Frame="Border" TableLayout="Auto">
<CommandItemTemplate>
...
</CommandItemTemplate>
<Columns>
...
</Columns>
<ExpandCollapseColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType"
Resizable="False" Visible="False">
<HeaderStyle Width="20px" />
</ExpandCollapseColumn>
<RowIndicatorColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType"
Visible="False">
<HeaderStyle Width="20px" />
</RowIndicatorColumn>
<EditFormSettings>
<EditColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType">
</EditColumn>
</EditFormSettings>
</MasterTableView>
<ClientSettings>
<Selecting AllowRowSelect="True" />
<ClientEvents OnRowDblClick="gridUsers_OnRowDblClick" OnRowSelected="RowSelected" />
</ClientSettings>
</telerik:RadGrid>
thanks
| <%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" ValidateRequest="true" %> |
| <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> |
| <!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>Untitled Page</title> |
| </head> |
| <body> |
| <form id="form1" runat="server"> |
| <div> |
| <asp:ScriptManager ID="ScriptManager" runat="server"></asp:ScriptManager> |
| <telerik:RadAjaxManager id="RadAjaxManager1" runat="server"></telerik:RadAjaxManager> |
| <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" EnableEmbeddedScripts="true" LoadingPanelID="LoadingPanel1" Width="100%"> |
| <asp:Button ID="btn1" runat="server" Text="btn1" /> |
| <a href="javascript:void();" id="lnkDocName" class="normal" runat="server" >blah-blah</a> |
| <telerik:RadToolTip |
| id="toolTip" |
| runat="server" |
| RelativeTo="Element" |
| ShowEvent="OnClick" |
| ShowCallout="false" |
| ManualClose="true" |
| Width="400" |
| ShowDelay="0" |
| Animation="Fade" |
| TargetControlID="lnkDocName" |
| > |
| <asp:Button ID="btn2" runat="server" Text="btn2" /> |
| </telerik:RadToolTip> |
| </telerik:RadAjaxPanel> |
| <telerik:RadAjaxLoadingPanel runat="Server" ID="LoadingPanel1" InitialDelayTime="0" Transparency="30" BackColor="#E0E0E0"> |
| <asp:Image id="Image1" runat="server" AlternateText="Loading..." BorderWidth="0px" ImageUrl="~/RadControls/AJAX/Skins/Default/loading.gif" style="margin-top:100px;"></asp:Image> |
| </telerik:RadAjaxLoadingPanel> |
| </div> |
| </form> |
| </body> |
| </html> |