Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
287 views
   public partial class _Default : System.Web.UI.Page 
    { 
        protected void Page_Load(object sender, EventArgs e) 
        { 
            if (!Page.IsPostBack) 
            { 
                Calendar.SelectedDate = DateTime.Now; 
              
            } 
 
 
        } 
 
        private void GetDays() 
        { 
             
        } 
 
        private void CreateSelectedCollection(Telerik.Web.UI.Calendar.Collections.DateTimeCollection coll, bool rebindgrid) 
        { 
 
            Dictionary<DateTime, Entry> dict = new Dictionary<DateTime, Entry>(); 
 
            StringBuilder b = new StringBuilder(); 
            for (int i = 0; i < coll.Count; i++) 
            { 
                dict.Add(coll[i].Date, new Entry(coll[i].Date, true, -1)); 
 
                b.Append("'"); 
                b.Append(coll[i].Date.ToString("yyyy-MM-dd")); 
                b.Append("'"); 
                if (i != coll.Count - 1) 
                    b.Append(","); 
            } 
            checkdates(b.ToString(), dict, rebindgrid); 
        } 
 
        private void checkdates(string p, Dictionary<DateTime, Entry> dict, bool rebindgrid) 
        { 
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["TimesheetConnectionString"].ConnectionString)) 
            { 
                conn.Open(); 
                SqlCommand comm = new SqlCommand("SELECT * FROM tblEntries WHERE Date IN( " + p + " )", conn); 
                SqlDataReader reader = comm.ExecuteReader(); 
 
                while (reader.Read()) 
                { 
                    if (dict.ContainsKey((DateTime)reader["Date"])) 
                    { 
                        dict[(DateTime)reader["Date"]].From = (DateTime)reader["From_"]; 
                        dict[(DateTime)reader["Date"]].To = (DateTime)reader["To_"]; 
                        dict[(DateTime)reader["Date"]].IsNewRecord = false
                        dict[(DateTime)reader["Date"]].ID = int.Parse(reader["ID"].ToString()); 
                    } 
 
                } 
            } 
            grid.DataSource = dict.Values; 
 
            if (rebindgrid) 
                grid.Rebind(); 
        } 
 
        protected void update(object source, Telerik.Web.UI.GridCommandEventArgs e) 
        {  
            Hashtable t = new Hashtable(); 
 
            GridEditableItem editedItem = e.Item as GridEditableItem; 
 
            e.Item.OwnerTableView.ExtractValuesFromItem(t, editedItem); 
 
 
        } 
 
 
        protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) 
        { 
            if (e.CommandName == "UpdateAll"
            { 
                foreach (GridEditableItem editedItem in grid.EditItems) 
                { 
                    Hashtable newValues = new Hashtable(); 
 
                    e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem); 
 
                    updateorinsert((string)newValues["To"], (string)newValues["From"], (bool)newValues["IsNewRecord"], (string)newValues["Date"], (string)newValues["ID"]); 
 
                    editedItem.Edit = false
                } 
            } 
            grid.Rebind(); 
        } 
 
        private void updateorinsert(string to, string from, bool isnew, string date, string id) 
        { 
 
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["TimesheetConnectionString"].ConnectionString)) 
            { 
 
                conn.Open(); 
 
 
                if ((isnew)) 
                { 
                    SqlCommand comm = new SqlCommand("INSERT INTO tblEntries (Date, To_, From_) VALUES (@Date, @To, @From)", conn); 
                    comm.Parameters.AddWithValue("@Date", DateTime.Parse(date).ToString("yyyy-MM-dd")); 
                    comm.Parameters.AddWithValue("@To", DateTime.Parse(to).ToString("yyyy-MM-dd HH:mm")); 
                    comm.Parameters.AddWithValue("@From", DateTime.Parse(from).ToString("yyyy-MM-dd HH:mm")); 
                    int result = comm.ExecuteNonQuery(); 
 
                } 
                else 
                { 
 
                    SqlCommand comm = new SqlCommand("UPDATE tblEntries SET Date = @Date, To_ = @To, From_ = @From WHERE ID = @Id", conn); 
 
                    comm.Parameters.AddWithValue("@Date", DateTime.Parse(date).ToString("yyyy-MM-dd")); 
                    comm.Parameters.AddWithValue("@To", DateTime.Parse(to).ToString("yyyy-MM-dd HH:mm")); 
                    comm.Parameters.AddWithValue("@From", DateTime.Parse(from).ToString("yyyy-MM-dd HH:mm")); 
                    comm.Parameters.AddWithValue("@Id"int.Parse(id)); 
 
                    int result = comm.ExecuteNonQuery(); 
 
                } 
 
                conn.Close(); 
            } 
        } 
 
 
        TimeSpan a; 
        protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
        { 
 
            if (e.Item is GridDataItem) 
            { 
 
 
                GridDataItem dataItem = e.Item as GridDataItem; 
                TimeSpan tmp; 
                if (TimeSpan.TryParse(dataItem["Span"].Text, out tmp)) 
                    a += (tmp); 
            } 
            if (e.Item is GridFooterItem) 
            { 
                GridFooterItem footerItem = e.Item as GridFooterItem; 
                footerItem["Span"].Text = "total: " + a.Hours + " h" + a.Minutes + " m"
            } 
        } 
 
        protected void RadGrid1_PreRender(object sender, System.EventArgs e) 
        { 
            // Force all rows to be in edit mode (rebind is called)  
 
            foreach (GridItem item in grid.MasterTableView.Items) 
                { 
                    if (item is GridEditableItem) 
                    { 
                        GridEditableItem editableItem = item as GridDataItem; 
                        editableItem.Edit = true
                    } 
                } 
                grid.Rebind(); 
             
        } 
 
 
        /// <summary> 
        /// Needdatasource event handler 
        /// </summary> 
        /// <param name="source"></param> 
        /// <param name="e"></param> 
         
        protected void need(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) 
        { 
             
 
             CreateSelectedCollection(Calendar.SelectedDates, false); 
 
             
        } 
 
     
        /// <summary> 
        /// Dateselected event handler 
        /// </summary> 
        /// <param name="sender"></param> 
        /// <param name="e"></param> 
        protected void fire(object sender, SelectedDatesEventArgs e) 
        { 
             
            
             CreateSelectedCollection(e.SelectedDates, true); 
        } 
 
 
        //protected void save() 
        //{ 
        
 
        //} 
 
 
 
 
 
    } 

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AJAXEnabledWebApplication1._Default" %> 
<%@ Register TagPrefix="telerik" Assembly="Telerik.Web.UI" Namespace="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"
        <asp:ScriptManager ID="ScriptManager1" runat="server" /> 
    <div> 
     
      <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true"
    
            <ContentTemplate> 
             
    <telerik:RadCalendar MultiViewColumns="6"  AutoPostBack="true" runat="server" ID="Calendar" UseColumnHeadersAsSelectors="false" UseRowHeadersAsSelectors="true" OnSelectionChanged="fire"    ShowRowHeaders="true" EnableMultiSelect="true"   /> 
     
    </ContentTemplate> 
    </asp:UpdatePanel> 
     
     
     
      
    
 
        <asp:UpdatePanel runat="server" ChildrenAsTriggers="true"
   
            <ContentTemplate> 
                <telerik:RadGrid  Skin="Vista" OnItemDataBound="RadGrid1_ItemDataBound" ShowFooter="true" AllowSorting="true" 
                    OnItemCommand="RadGrid1_ItemCommand" OnPreRender="RadGrid1_PreRender" OnNeedDataSource="need" 
                      OnUpdateCommand="update" AutoGenerateColumns="false" runat="server" ID="grid" 
                    AllowMultiRowEdit="true"
                     
                     
                    <ExportSettings> 
                        <Excel FileExtension="xls" Format="ExcelML" /> 
                        <Csv FileExtension="txt" RowDelimiter="NewLine" ColumnDelimiter="semicolon" /> 
                        <Pdf Title="Timerapport" Producer="TimeSys" PaperSize="a4" PageTitle="TimeRapport" 
                            AllowPrinting="true" AllowCopy="true" AllowAdd="true" FontType="Embed" /> 
                    </ExportSettings> 
                    <MasterTableView EditMode="inplace" CommandItemDisplay="topAndBottom"
                        <Columns> 
                            
                            <telerik:GridDateTimeColumn DataField="Date" HeaderText="Dato" ReadOnly="false"
                            </telerik:GridDateTimeColumn> 
                            <telerik:GridDateTimeColumn DataField="From" HeaderText="Fra" PickerType="TimePicker"
                            </telerik:GridDateTimeColumn> 
                            <telerik:GridDateTimeColumn  DataField="To" HeaderText="Til" PickerType="TimePicker"
                            </telerik:GridDateTimeColumn> 
                            <telerik:GridCheckBoxColumn ReadOnly="false" DataField="IsNewRecord" Visible="false" /> 
                            <telerik:GridBoundColumn ReadOnly="false" DataField="ID" Visible="false" /> 
                            <telerik:GridBoundColumn ReadOnly="true" DataField="Span" UniqueName="Span"  Visible="true" HeaderText="Antall timer" /> 
                            <telerik:GridTemplateColumn DataField="TimeSp"
                                <ItemTemplate> 
                                    <asp:Literal Text='<%# Eval("TimeSp") %>' runat="server" /> 
                                </ItemTemplate> 
                                <FooterTemplate> 
                                </FooterTemplate> 
                            </telerik:GridTemplateColumn> 
                        </Columns> 
                        <CommandItemTemplate> 
                            <asp:Button runat="server" ID="UpdateAll" Text="Update 
All" CommandName="UpdateAll" />                 
                      
                        </CommandItemTemplate> 
                    </MasterTableView> 
     
    </telerik:RadGrid> 
    </ContentTemplate> 
     
    </asp:UpdatePanel> 
     
     
     
    </div> 
    </form> 
</body> 
</html> 
 

Hello, I'm creating a small timesheet application, it has a custom total row which sums up the rows in the grid. The problem is that even though the itemdatabound event is fired, the .Text property is empty so i end up getting the wrong totals.

Missing User
 answered on 20 Aug 2008
1 answer
278 views
Hi

Just about to use the FormDecorator for the first time and notice that on your samples page (http://www.telerik.com/demos/aspnet/Prometheus/FormDecorator/Examples/Skinning/DefaultCS.aspx) the Office 2007 skin seems to be the same as the Vista skin. Office 2007 buttons have an orange graduation on hover not a blue border!

Thanks
Russell Mason
Georgi Tunev
Telerik team
 answered on 20 Aug 2008
1 answer
129 views
Hello!

In my Test - ASPX file, there is a control which seems to be ajaxified, but i didn't make the settings for this.

I have two asp:DropDownLists inside of a asp:Panel(TestPanel).
Outside of this Panel there exists a hidden button which will never raise an event(it is also hidden).

This button is ajaxified an updates the panel below.

In code-behind in the OnSelectedIndexChange of the first combobox, the second combobox is set to the same "SelectedIndex".

When I start the website and change now the first dropdownlist, the value of the second one changes also on the website. But there is no Ajax - Setting which enforces this behaviour. Why is the second one updated?
It seems to me, if a postback is called out of an "UpdatedControl", that the whole control is updated, regardless to which control calls the postback.

I also noticed, that there is NO postback, which refreshes the whole site. The post which is sent seems to be an ajax request(small amount of time for the request, no refreshing of the whole page is noticeable), but the ClientEvent
"OnRequestStart" is never called. So how can it be, that it seems to be an ajax request without calling the client events?

Here my aspx file:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AjaxTest.aspx.cs" Inherits="TestWebPerformance.TestUsercontrol.AjaxTest" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %> 
 
 
<!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>Ajax test</title> 
</head> 
<body style="background-color: Gray;">  
    <form id="form1" runat="server">  
        <asp:ScriptManager ID="ScriptManager1" runat="server">  
        </asp:ScriptManager> 
 
        <telerik:RadAjaxManager ID="ajaxManager" runat="server">  
            <ClientEvents OnRequestStart="alert('now')" /> 
            <AjaxSettings> 
                <telerik:AjaxSetting AjaxControlID="btnTabTrigger">  
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="TestPanel" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
            </AjaxSettings> 
        </telerik:RadAjaxManager> 
          
        <div style="display: none;">  
            <asp:Button ID="btnTabTrigger" OnClick="RadTabStrip_Triggered" runat="server" /> 
        </div> 
          
        <asp:Panel ID="TestPanel" runat="server">  
            <asp:DropDownList ID="test" AutoPostBack="true" OnSelectedIndexChanged="test_OnSelectedIndexChanged" runat="server">  
            </asp:DropDownList> 
          
            <asp:DropDownList ID="cbo3" runat="server">  
            </asp:DropDownList> 
        </asp:Panel> 
 
    </form> 
</body> 
</html> 
 

and here my code behind:
using System;  
using System.Collections;  
using System.Configuration;  
using System.Data;  
using System.Linq;  
using System.Web;  
using System.Web.Security;  
using System.Web.UI;  
using System.Web.UI.HtmlControls;  
using System.Web.UI.WebControls;  
using System.Web.UI.WebControls.WebParts;  
using System.Xml.Linq;  
 
namespace TestWebPerformance.TestUsercontrol  
{  
    public partial class AjaxTest : System.Web.UI.Page  
    {  
        protected void Page_Load(object sender, EventArgs e)  
        {  
            if (!Page.IsPostBack)  
            {  
                test.Items.Add(new ListItem("t1", "0"));  
                test.Items.Add(new ListItem("t2", "1"));  
                test.Items.Add(new ListItem("t3", "2"));  
                cbo3.Items.Add(new ListItem("main1", "0"));  
                cbo3.Items.Add(new ListItem("main2", "1"));  
                cbo3.Items.Add(new ListItem("main3", "2"));  
            }  
        }  
 
 
        protected void test_OnSelectedIndexChanged(object sender, EventArgs e)  
        {  
            cbo3.SelectedIndex = test.SelectedIndex;  
        }  
    }  
}  
 

Thank you very much!

Dimo
Telerik team
 answered on 20 Aug 2008
5 answers
207 views
In the appointment created event, I want to access the Resource drop down.  Is it possible through that event?  I want to apply css based on what drop down item is selected.  The example on the website uses e.appointment.subject, but is there a way to get to the appointments resource drop down?
Peter
Telerik team
 answered on 20 Aug 2008
2 answers
113 views
Hi,

For storing the State of a RadDock layout in a database, we have a State column of type varchar. I was just wondering what the optimum length of the datatype should be?

I have seen various code examples on here from Telerik where the State datatype length has been varchar(1000) but also examples where varchar(MAX) has been used. What is the recommended datatype length to use in production? Good db design obviously suggests we go as small as possible but always 'big enough' so this is quite important... 
Adam Hubble
Top achievements
Rank 1
 answered on 20 Aug 2008
1 answer
194 views
Hi,

Is it possible to place a RadGrid inside a RadPanelItem? I tried to insert a RadGrid into the ItemTemplate but that will always bring a compiling error claiming that the RadGrid is not defined.

The xml I used is as follows:

<telerik:RadPanelBar ID="RadPanelBar1" runat="server" Skin="Outlook">

<Items>

<telerik:RadPanelItem Text="Browser">

<ItemTemplate>

<

telerik:RadGrid ID="RadGrid1" runat="server" ... >

</telerik:RadGrid>

</

ItemTemplate>

</

Items>

</

telerik:RadPanelItem>

Thanks.

Princy
Top achievements
Rank 2
 answered on 20 Aug 2008
2 answers
96 views
All form HTML elements implement a DOM property to allow a form's reset to function. In JavaScript I can access these as follows:

obj.defaultChecked
obj.defaultValue
obj.defaultSelected

What is the DOM equivalent for the Telerik controls on the client side?

I need to be able to determine if any of the controls on my page have changed from their default value and prompt the user to save them when they attempt to navigate away from the page. I'm using both versions 1.7.2.0 & 2008.2.723.20
Daniel
Telerik team
 answered on 20 Aug 2008
5 answers
149 views
Hi,

Scenario:
 A user enters details in many text boxes in many web pages which is stored into a SQL database. On one of the web pages I have a spreadsheet application that allows the user to enter text and select from drop down boxes not just on one sheet. I have to use just one spell check button on the final web page to spell check every piece of text entered. This means retrieving data from the database cell by cell checking it then if edited by the user to update the database. Can this be done using telerik spell checker?

Thanks
Paul
Paul
Top achievements
Rank 1
 answered on 20 Aug 2008
1 answer
122 views
We have a treeview and a grid on a page.  I have the ajax manager set up as follows:
<telerik:AjaxSetting AjaxControlID="RadAjaxManager1">  
    <UpdatedControls> 
         <telerik:AjaxUpdatedControl ControlID="RepositoryTree"/>  
         <telerik:AjaxUpdatedControl ControlID="PortfolioGrid"/>  
    </UpdatedControls> 
</telerik:AjaxSetting> 
<telerik:AjaxSetting AjaxControlID="PortfolioGrid">  
    <UpdatedControls> 
    <telerik:AjaxUpdatedControl ControlID="PortfolioGrid" /> 
    </UpdatedControls> 
</telerik:AjaxSetting> 
<telerik:AjaxSetting AjaxControlID="RepositoryTree">  
    <UpdatedControls> 
    <telerik:AjaxUpdatedControl ControlID="RepositoryTree" /> 
    <telerik:AjaxUpdatedControl ControlID="PortfolioGrid" /> 
    </UpdatedControls> 
</telerik:AjaxSetting> 
 

This does work, but when operations are done on the treeview (RepositoryTree), the grid (PortfolioGrid) is always updated too, when in actuality, there are only certain operations that require the grid to be updated (for example, drag/dropping an item from the treeview to the grid).  So on updates to the treeview, I always want the treeview updated, but only sometimes do I want the grid updated.

But, I've been unable to figure out how to manually trigger the ajax call to update the grid upon a drop, if I remove the last "updatedControl" line from the declaration above like this:
<telerik:AjaxSetting AjaxControlID="RepositoryTree">  
    <UpdatedControls> 
    <telerik:AjaxUpdatedControl ControlID="RepositoryTree" /> 
    </UpdatedControls> 
</telerik:AjaxSetting>

I've tried adding ajaxManager.ajaxRequestWithTarget or ajaxManager.ajaxRequest 
calls to specifically update the grid, but they do nothing, perhaps because other ajax activity is already going on (the primary RepositoryTree work is happening via Ajax)?  Perhaps I haven't found the right place to add the api calls for ajax on the Grid?  In this example, we do have a serverside method to process the drop on the grid in response to the OnNodeDrop event.  Seems like I would have to make Grid ajax refresh request after this event returns to the client?  How would I do that?

Thanks,
Sheryl
Maria Ilieva
Telerik team
 answered on 20 Aug 2008
4 answers
174 views
Hello,
I am using 2008.1.416.20 of telerik and trying to set the text within the combo input area. I am using the following but am not able to get the text to change:
.RadComboBox_Web20 .rcbInputCell  
{  
    font: normal 8px Arial, Verdana, Sans-serif;  

I also tried:

.RadComboBox_Web20 .rcbInputCell table, td  
{  
    font: normal 8px Arial, Verdana, Sans-serif;  

But this seems to also set the text within a grid on the same page and it still does not have any effect on the text in the combo input area?

I am able to to set the cursor property of the arrow with:

.RadComboBox_Web20 .rcbArrowCell  
{  
    cursor: pointer;  

So I guess I must be doing something right?

Thanks!
Rosi
Telerik team
 answered on 20 Aug 2008
Narrow your results
Selected tags
Tags
+? more
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?