RadDatePicker and RadEditor Binding in a DetailsView

3 posts, 0 answers
  1. Drammy
    Drammy avatar
    38 posts
    Member since:
    Feb 2008

    Posted 24 Jun 2008 Link to this post

    Hi all,

    I have grid that on insert / edit opens a RadWindow using functionality I have found on this website.  This default functionality uses a default view to present the edit form and I have amended it slightly changing two of the text boxes to a RadDatePicker and a RadEditor.  These additional RadControls bind properly but the binding appears to only be one way.  Upon update/insert any data in these RadControls is ignored and only the data from the text boxes goes into the database.

    Can anyopne help me out please?  I have attached the code below:

    PersonEditForm.aspx
    1 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PersonEditForm.aspx.cs" Inherits="HonoursBoard.Admin.PersonEditForm" %> 
    2 <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
    3  
    4 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    5  
    6 <html xmlns="http://www.w3.org/1999/xhtml" > 
    7     <head id="Head1" runat="server">  
    8         <title>Untitled Page</title> 
    9     </head> 
    10     <body> 
    11         <form id="form1" runat="server">  
    12             <telerik:RadScriptManager ID="RadScriptManager1" runat="server">  
    13             </telerik:RadScriptManager> 
    14             <div> 
    15                 <script type="text/javascript">  
    16                 function CloseAndRebind(args)  
    17                 {  
    18                     GetRadWindow().Close();  
    19                     GetRadWindow().BrowserWindow.refreshGrid(args);  
    20                 }  
    21                        
    22                 function GetRadWindow()  
    23                 {  
    24                     var oWindow = null;  
    25  
    26                     if (window.radWindow)  
    27                         oWindow = window.radWindow; //Will work in Moz in all cases, including classic dialog  
    28                     else if (window.frameElement.radWindow)  
    29                         oWindow = window.frameElement.radWindow;//IE (and Moz as well)  
    30                         return oWindow;  
    31                  }  
    32                  function CancelEdit()  
    33                  {  
    34                     GetRadWindow().Close();    
    35                  }  
    36                 </script> 
    37                 <asp:DetailsView ID="DetailsView1" DataKeyNames="intPersonID" runat="server" AutoGenerateRows="False" 
    38                     DataSourceID="SqlDataSource1" Height="50px" Width="125px" OnItemCommand="DetailsView1_ItemCommand">  
    39                     <Fields> 
    40                         <asp:BoundField DataField="strTitle" HeaderText="Title" SortExpression="strTitle" /> 
    41                         <asp:BoundField DataField="strFirstName" HeaderText="First Name" SortExpression="strFirstName" /> 
    42                         <asp:BoundField DataField="strInitials" HeaderText="Initials" SortExpression="strInitials" /> 
    43                         <asp:BoundField DataField="strLastName" HeaderText="Last Name" SortExpression="strLastName" /> 
    44                         <asp:TemplateField HeaderText="Date Of Birth">  
    45                             <ItemTemplate> 
    46                                 <telerik:RadDatePicker EnableViewState="false" MinDate="01/01/1850" 
    47                                     MaxDate="01/01/2100" Skin="Telerik" ID="RadDatePicker1" 
    48                                     DbSelectedDate='<%# DataBinder.Eval(Container.DataItem, "datDateOfBirth") %>' 
    49                                     Runat="server"></telerik:RadDatePicker> 
    50                             </ItemTemplate> 
    51                         </asp:TemplateField> 
    52                         <asp:TemplateField HeaderText="Biography">  
    53                             <ItemTemplate> 
    54                                 <telerik:RadEditor EnableViewState="false" ID="RadEditor1" runat="server" Skin="Telerik" 
    55                                     ToolsFile="~/Editor/BasicTools.xml" Width="400px" Height="200px" 
    56                                     Content='<%# DataBinder.Eval(Container.DataItem, "strBiography") %>'>  
    57                                 </telerik:RadEditor> 
    58                             </ItemTemplate> 
    59                         </asp:TemplateField> 
    60                         <asp:CommandField ShowEditButton="True" /> 
    61                         <asp:CommandField ShowInsertButton="True" InsertText="Add" /> 
    62                     </Fields> 
    63                 </asp:DetailsView> 
    64             </div> 
    65             <asp:SqlDataSource ID="SqlDataSource1" runat="server"   
    66                 ConnectionString="<%$ ConnectionStrings:dbGolfHonoursConnectionString %>"   
    67                 InsertCommand="InsertAPerson" InsertCommandType="StoredProcedure"   
    68                 SelectCommand="SelectPersonByPersonID" SelectCommandType="StoredProcedure"   
    69                 UpdateCommand="UpdateAPerson" UpdateCommandType="StoredProcedure">  
    70                 <SelectParameters> 
    71                     <asp:QueryStringParameter DefaultValue="0" Name="PersonID"   
    72                         QueryStringField="intPersonID" Type="Int32" /> 
    73                 </SelectParameters> 
    74                 <UpdateParameters> 
    75                     <asp:Parameter Name="intPersonID" Type="Int32" /> 
    76                     <asp:Parameter Name="strTitle" Type="String" /> 
    77                     <asp:Parameter Name="strFirstName" Type="String" /> 
    78                     <asp:Parameter Name="strInitials" Type="String" /> 
    79                     <asp:Parameter Name="strLastName" Type="String" /> 
    80                     <asp:Parameter Name="strBiography" Type="String" /> 
    81                     <asp:Parameter Name="datDateOfBirth" Type="DateTime" /> 
    82                 </UpdateParameters> 
    83                 <InsertParameters> 
    84                     <asp:Parameter Name="strTitle" Type="String" /> 
    85                     <asp:Parameter Name="strFirstName" Type="String" /> 
    86                     <asp:Parameter Name="strInitials" Type="String" /> 
    87                     <asp:Parameter Name="strLastName" Type="String" /> 
    88                     <asp:Parameter Name="strBiography" Type="String" /> 
    89                     <asp:Parameter Name="datDateOfBirth" Type="DateTime" /> 
    90                 </InsertParameters> 
    91             </asp:SqlDataSource> 
    92         </form> 
    93     </body> 
    94 </html> 


    PersonEditForm.aspx.cs
    1 using System;  
    2 using System.Collections;  
    3 using System.Configuration;  
    4 using System.Data;  
    5 using System.Linq;  
    6 using Telerik.Web.UI;  
    7 using System.Web;  
    8 using System.Web.Security;  
    9 using System.Web.UI;  
    10 using System.Web.UI.HtmlControls;  
    11 using System.Web.UI.WebControls;  
    12 using System.Web.UI.WebControls.WebParts;  
    13 using System.Xml.Linq;  
    14  
    15 namespace HonoursBoard.Admin  
    16 {  
    17     public partial class PersonEditForm : System.Web.UI.Page  
    18     {  
    19         protected void Page_Init(object sender, EventArgs e)  
    20         {  
    21             if (Request.QueryString["intPersonID"] == null)  
    22             {  
    23                 DetailsView1.DefaultMode = DetailsViewMode.Insert;  
    24             }  
    25             else 
    26             {  
    27                 DetailsView1.DefaultMode = DetailsViewMode.Edit;  
    28             }  
    29         }  
    30  
    31         protected void DetailsView1_ItemCommand(object sender, System.Web.UI.WebControls.DetailsViewCommandEventArgs e)  
    32         {  
    33             if (e.CommandName == "Update")  
    34             {  
    35                 ClientScript.RegisterStartupScript(Page.GetType(), "mykey""CloseAndRebind();"true);  
    36             }  
    37             else if (e.CommandName == "Insert")  
    38             {  
    39                 ClientScript.RegisterStartupScript(Page.GetType(), "mykey""CloseAndRebind('navigateToInserted');"true);  
    40             }  
    41             else 
    42             {  
    43                 ClientScript.RegisterStartupScript(Page.GetType(), "mykey""CancelEdit();"true);  
    44             }  
    45         }  
    46     }  
    47

    Thanks in advance for any help offered,

    Martyn
  2. Drammy
    Drammy avatar
    38 posts
    Member since:
    Feb 2008

    Posted 24 Jun 2008 Link to this post

    Please ignore my stupidity!

    Problem solved - I guess I need to grab me some sleep!

    I had it in my head I was using Bind() rather than an outdated Eval function...


    Sorry to waste anyone's time reading this thread.
  3. Hoon
    Hoon avatar
    7 posts
    Member since:
    Oct 2010

    Posted 08 Jul 2011 Link to this post

    Your foolishness saves a lot of Genius.
Back to Top