Hi there
I am experiencing the following problems when I try to rebuild this example in a application : window example
First: the edit button on the right-next collum of the grid isnt working
Second: Whenever I insert or update a record the Insert/Edit window remains open and the grid isn not refreshed.
Can you help me solving this problems?
I am experiencing the following problems when I try to rebuild this example in a application : window example
First: the edit button on the right-next collum of the grid isnt working
Second: Whenever I insert or update a record the Insert/Edit window remains open and the grid isn not refreshed.
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="DefaultCS.aspx.cs" Inherits="TelerikRadDemo.Home" %><%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %><asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="RadGrid1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <br /> <telerik:RadMenu ID="RadMenu1" runat="server" OnItemClick="RadMenu1_ItemClick" Style="top: 19px; left: 0px" Skin="Metro"> <Items> <telerik:RadMenuItem runat="server" Text="Open"> <Items> <telerik:RadMenuItem runat="server" Text="Cars"> </telerik:RadMenuItem> <telerik:RadMenuItem runat="server" Text="Manufactures"> </telerik:RadMenuItem> <telerik:RadMenuItem runat="server" Text="Customers"> </telerik:RadMenuItem> </Items> </telerik:RadMenuItem> <telerik:RadMenuItem runat="server" Text="Help"> <Items> <telerik:RadMenuItem runat="server" Text="Visit Golem webpage"> </telerik:RadMenuItem> <telerik:RadMenuItem runat="server" Text="About us"> </telerik:RadMenuItem> </Items> </telerik:RadMenuItem> </Items> </telerik:RadMenu> <br /> <br /> <telerik:RadToolBar ID="RadToolBar1" Runat="server" Skin="Metro" > <Items> <telerik:RadToolBarButton runat="server" Text="Add" onclick="return ShowInsertForm();"> </telerik:RadToolBarButton> <telerik:RadToolBarButton runat="server" Text="Delete"> </telerik:RadToolBarButton> <telerik:RadToolBarButton runat="server" Text="Edit"> </telerik:RadToolBarButton> <telerik:RadToolBarButton runat="server" Text="Next"> </telerik:RadToolBarButton> <telerik:RadToolBarButton runat="server" Target="_previous" Text="Previous"> </telerik:RadToolBarButton> </Items> </telerik:RadToolBar> <br /> <div> <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> <script type="text/javascript"> function ShowEditForm(id, rowIndex) { var grid = $find("<%= RadGrid1.ID %>"); var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element(); grid.get_masterTableView().selectItem(rowControl, true); window.radopen("EditFormCS.aspx?ID=" + id, "UserListDialog"); return false; } function ShowInsertForm() { window.radopen("EditFormCS.aspx", "UserListDialog"); return false; } function refreshGrid(arg) { if (!arg) { $find("<%= RadAjaxManager1.ID %>").ajaxRequest("Rebind"); } else { $find("<%= RadAjaxManager1.ID %>").ajaxRequest("RebindAndNavigate"); } } function RowDblClick(sender, eventArgs) { window.radopen("EditFormCS.aspx?ID=" + eventArgs.getDataKeyValue("ID"), "UserListDialog"); }// var selected = {};// function RadGrid1_RowSelected(sender, args) {// var ID = args.getDataKeyValue("ID");// if (!selected[ID]) {// selected[ID] = true;// }// }// function RadGrid1_RowDeselected(sender, args) {// var ID = args.getDataKeyValue("ID");// if (selected[ID]) {// selected[ID] = null;// }// }// function RadGrid1_RowCreated(sender, args) {// var ID = args.getDataKeyValue("ID");// if (selected[ID]) {// args.get_gridDataItem().set_selected(true);// }// }// function GridCreated(sender, eventArgs) {// var masterTable = sender.get_masterTableView();// //check whether all items on the active page are selected // if (masterTable.get_selectedItems().length == masterTable.get_pageSize()) {// /*find the checkbox in the header of the GridClientSelectColumn and set checked state for it - will work with AllowMultiRowSelection = true only!*/// var gridHeader = masterTable.get_element().getElementsByTagName("TH")[0];// for (var i = 0; i < gridHeader.childNodes.length; i++) {// if (gridHeader.childNodes[i].id.indexOf("columnSelectCheckBox") > -1) {// gridHeader.childNodes[i].checked = "true";// }// }// }// } </script> </telerik:RadCodeBlock> <telerik:RadGrid OnItemCreated="RadGrid1_ItemCreated" ID="RadGrid1" runat="server" AllowPaging="True" Width="97%" DataSourceID="SqlDataSource1" Skin="Metro" AllowMultiRowSelection="true"> <PagerStyle Mode="NumericPages" /> <MasterTableView AutoGenerateColumns="False" DataKeyNames="ID" ClientDataKeyNames="ID" Width="100%" CommandItemDisplay="Top" PageSize="5"> <Columns> <telerik:GridBoundColumn DataField="ID" HeaderText="ID" ReadOnly="True" SortExpression="ID" UniqueName="ID"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Manufacture" HeaderText="Manufacture" SortExpression="Manufacture" UniqueName="Manufacture"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Name" HeaderText="Name" SortExpression="Name" UniqueName="Name"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Year" HeaderText="Year" SortExpression="Year" UniqueName="Year"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Price" HeaderText="Price" ReadOnly="True" SortExpression="Price" UniqueName="Price"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Information" HeaderText="Information" ReadOnly="True" SortExpression="Information" UniqueName="Information"> </telerik:GridBoundColumn> <telerik:GridTemplateColumn UniqueName="TemplateEditColumn"> <ItemTemplate> <asp:HyperLink ID="EditLink" runat="server" Text="Edit"></asp:HyperLink> </ItemTemplate> </telerik:GridTemplateColumn> </Columns> <CommandItemTemplate> <a href="#" onclick="return ShowInsertForm();">Add New Record</a> </CommandItemTemplate> </MasterTableView> <ClientSettings> <Selecting AllowRowSelect="true" /> <ClientEvents OnRowDblClick="RowDblClick" /> </ClientSettings> </telerik:RadGrid> <telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true" Skin="Metro"> <Windows> <telerik:RadWindow ID="UserListDialog" runat="server" Title="Editing record" Height="320px" Width="310px" Left="150px" ReloadOnShow="true" ShowContentDuringLoad="false" Modal="true" /> </Windows> </telerik:RadWindowManager> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TelerikCars %>" SelectCommand="SELECT [ID], [Manufacture], [Name], [Year], [Price], [Information] FROM [Cars]"> </asp:SqlDataSource> <br /> </div></asp:Content><%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="EditFormCS.aspx.cs" Inherits="TelerikRadDemo.EditFormCS" %><%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %><asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <div> <script type="text/javascript"> function CloseAndRebind(args) { GetRadWindow().BrowserWindow.refreshGrid(args); GetRadWindow().close(); } function GetRadWindow() { var oWindow = null; if (window.radWindow) oWindow = window.radWindow; else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; return oWindow; } function CancelEdit() { GetRadWindow().close(); } </script> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" Skin="Metro" DecoratedControls="All" /> <br /> <br /> <asp:DetailsView ID="DetailsView1" DataKeyNames="ID" runat="server" AutoGenerateRows="False" DataSourceID="SqlDataSource1" Height="50px" Width="125px" OnItemCommand="DetailsView1_ItemCommand" BorderWidth="0" CellPadding="0" CellSpacing="7" GridLines="None" OnItemUpdating="DetailsView1_ItemUpdating"> <Fields> <asp:BoundField DataField="Manufacture" HeaderText="Car manufacture" SortExpression="Manufacture" /> <asp:BoundField DataField="Name" HeaderText="Car" SortExpression="Name" /> <asp:BoundField DataField="Year" HeaderText="Year of deploymnet" SortExpression="Year" /> <asp:BoundField DataField="Price" HeaderText="Current Price" SortExpression="Price" /> <asp:BoundField DataField="Information" HeaderText="Information" SortExpression="Information" /> <asp:CommandField ShowEditButton="True" ButtonType="Button" /> <asp:CommandField ShowInsertButton="True" ButtonType="Button" /> </Fields> </asp:DetailsView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TelerikCars %>" InsertCommand="INSERT INTO [Cars] ([Manufacture], [Name], [Year], [Price], [Information]) VALUES (@Manufacture, @Name, @Year, @Price, @Information)" SelectCommand="SELECT [ID], [Manufacture], [Name], [Year], [Price], [Information] FROM [Cars] WHERE ([ID] = @ID)" UpdateCommand="UPDATE [Cars] SET [Manufacture] = @Manufacture, [Name] = @Name, [Year] = @Year, [Price] = @Price, [Information] = @Information WHERE [ID] = @ID"> <InsertParameters> <asp:Parameter Name="Manufacture" Type="String" DefaultValue="" ConvertEmptyStringToNull="false" /> <asp:Parameter Name="Name" Type="String" DefaultValue="" ConvertEmptyStringToNull="false" /> <asp:Parameter Name="Year" Type="String" DefaultValue="" ConvertEmptyStringToNull="false" /> <asp:Parameter Name="Price" Type="String" DefaultValue="" ConvertEmptyStringToNull="false" /> <asp:Parameter Name="Information" Type="String" /> </InsertParameters> <UpdateParameters> <asp:Parameter Name="Manufacture" Type="String" DefaultValue="" ConvertEmptyStringToNull="false" /> <asp:Parameter Name="Name" Type="String" DefaultValue="" ConvertEmptyStringToNull="false" /> <asp:Parameter Name="Year" Type="String" DefaultValue="" ConvertEmptyStringToNull="false" /> <asp:Parameter Name="Price" Type="String" DefaultValue="" ConvertEmptyStringToNull="false" /> <asp:Parameter Name="Information" Type="String" /> <asp:Parameter Name="ID" Type="Int32" /> </UpdateParameters> <SelectParameters> <asp:QueryStringParameter Name="ID" QueryStringField="ID" Type="Int32" /> </SelectParameters> </asp:SqlDataSource> <br /> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </div></asp:Content>Can you help me solving this problems?