Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
278 views
Hi,

I have a grid with 4 columns:
Column 1 - an editable GridDateTimeColumn which displays and accepts a date
Column 2 - an editable GridNumericColumn which displays and accepts an integer
Column 3 - an editable GridBoundColumn which displays and accepts a string
Column 4 - a GridEditCommandColumn

The grid is created at runtime (instead of at design time).

I get the following error message:
"Editor cannot be initialized for column: Date"
when I exit from the edit mode by either clicking Update or Cancel button on the GridEditCommandColumn.

Can you please show me what I have missed or done wrong in my code?

The web page is available on http://www.gouw.ws/RadGrid/DynamicGrid.aspx

The source code is given below:

ASPX:
=====
<form id="form1" runat="server">
<div>
    <telerik:RadScriptManager ID="radScriptManager" runat="server" />
    <telerik:RadGrid ID="radGrid" AutoGenerateColumns="false" GridLines="Vertical" OnNeedDataSource="radGrid_NeedDataSource" OnUpdateCommand="radGrid_UpdateCommand" runat="server">
        <ClientSettings>
            <Scrolling UseStaticHeaders="true" />
        </ClientSettings>
        <MasterTableView EditMode="InPlace" TableLayout="Fixed">
        </MasterTableView>
    </telerik:RadGrid>
</div>
</form>

C#:
===
public partial class DynamicGrid : System.Web.UI.Page
{
    private List<Data> _data = null;

    protected void Page_Load(object sender, EventArgs e)
    {
        BuildGrid();

        if (!IsPostBack)
        {
            this._data = Data.Load();
            Session["DATA"] = this._data;
        }
        else
        {
            this._data = (List<Data>)Session["DATA"];
        }
    }

    protected void radGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
    {
        this.radGrid.DataSource = this._data;
    }

    protected void radGrid_UpdateCommand(object sender, GridCommandEventArgs e)
    {
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        {
            GridEditableItem item = e.Item as GridEditableItem;
            ((Data)(this._data[item.ItemIndex])).Date = (item["Date"].Controls[0] as RadDatePicker).SelectedDate.Value.Date;
            ((Data)(this._data[item.ItemIndex])).Value = int.Parse((item["Value"].Controls[0] as RadNumericTextBox).Text);
            ((Data)(this._data[item.ItemIndex])).Description = (item["Description"].Controls[0] as TextBox).Text;
        }
    }

    private void BuildGrid()
    {
        this.radGrid.Columns.Clear();

        GridDateTimeColumn dateColumn = new GridDateTimeColumn();
        dateColumn.DataField = "Date";
        dateColumn.HeaderText = "Date";
        dateColumn.UniqueName = "Date";
        this.radGrid.Columns.Add(dateColumn);
        this.radGrid.MasterTableView.Columns[0].HeaderStyle.Width = Unit.Percentage(13);
        this.radGrid.MasterTableView.Columns[0].ItemStyle.HorizontalAlign = HorizontalAlign.Left;

        GridNumericColumn valueColumn = new GridNumericColumn();
        valueColumn.DataField = "Value";
        valueColumn.HeaderText = "Value";
        valueColumn.UniqueName = "Value";
        this.radGrid.Columns.Add(valueColumn);
        this.radGrid.MasterTableView.Columns[1].HeaderStyle.Width = Unit.Percentage(13);
        this.radGrid.MasterTableView.Columns[1].ItemStyle.HorizontalAlign = HorizontalAlign.Left;

        GridBoundColumn descriptionColumn = new GridBoundColumn();
        descriptionColumn.DataField = "Description";
        descriptionColumn.HeaderText = "Description";
        descriptionColumn.UniqueName = "Description";
        this.radGrid.Columns.Add(descriptionColumn);
        this.radGrid.MasterTableView.Columns[2].HeaderStyle.Width = Unit.Percentage(64);
        this.radGrid.MasterTableView.Columns[2].ItemStyle.HorizontalAlign = HorizontalAlign.Left;

        GridEditCommandColumn editColumn = new GridEditCommandColumn();
        editColumn.ButtonType = GridButtonColumnType.LinkButton;
        editColumn.UniqueName = "Edit";
        this.radGrid.Columns.Add(editColumn);   
    }
}

public class Data
{
    public DateTime Date { get; set; }
    public int Value { get; set; }
    public string Description { get; set; }

    public Data(DateTime date, int value, string description)
    {
        Date = date;
        Value = value;
        Description = description;
    }

    public static List<Data> Load()
    {
        List<Data> data = new List<Data>();
        data.Add(new Data(DateTime.Now, 1, "This date is today"));
        data.Add(new Data(DateTime.Now.AddDays(1), 2, "This date is tomorrow"));
        data.Add(new Data(DateTime.Now.AddDays(2), 3, "This date is the day after tomorrow"));
        return data;
    }
}

Thanks & regards,
Herman Gouw
Skype: hermangouw
Yavor
Telerik team
 answered on 10 Aug 2009
1 answer
79 views
I finally changed my way to bind and used the new linqdatasource. The problem i have ist that ItemDataBound not works as expected. I thought that using an entity (e.g. user) in the linq datasource i should get the entity in itemdatabound via e.Item.DataItem.

What's wrong? How to get the data? Do i really have to reread the data on the database?
Nikolay Rusev
Telerik team
 answered on 10 Aug 2009
1 answer
62 views
Hi,
1.I am using the radCombo box in my project, In design time the following error comes "Could not load for assembly "Telerik.Web.Ui,Version=2009.2701.35,Culture=neutral, PublicKeyToken=121fae78165ba3d4' or one of its dependencies the system cannot find the file specified".

2.I could able to Run the application.

Thanks
Sabarish
Helen
Telerik team
 answered on 10 Aug 2009
1 answer
136 views
I have a RadGrid with a datatable as it's source.
I have AllowCustomPaging set to true.

    <telerik:RadGrid runat="server" ID="RadGridSearchResults" 
    PageSize="50" AllowPaging="true" AllowCustomPaging="true" 
    OnNeedDataSource="RadGridSearchResults_NeedDataSource" Skin="Default"
    <PagerStyle Mode="NextPrevNumericAndAdvanced" /> 
    </telerik:RadGrid> 


The code for my code behind method RadGridSearchResults_NeedDataSource just fills and returns a datatable with the following columns:

    dataTableSearchResults.Columns.Add("recipeId"typeof(string)); 
    dataTableSearchResults.Columns.Add("ingredientsIds"typeof(string)); 
    dataTableSearchResults.Columns.Add("country"typeof(string)); 
    dataTableSearchResults.Columns.Add("author"typeof(string)); 
    dataTableSearchResults.Columns.Add("style"typeof(string)); 
    dataTableSearchResults.Columns.Add("friendly"typeof(string)); 
    dataTableSearchResults.Columns.Add("name"typeof(string)); 


Once the RadGrid is databound, I run the following:

    var expression = GridGroupByExpression.Parse( 
    "recipeId [Recipe], count(recipeId) ingredientsIds [Ingredients]
    Group By recipeId"); 
    this.RadGridSearchResults.MasterTableView.GroupByExpressions.Add(expression); 
    this.RadGridSearchResults.GroupingEnabled = true

I would expect my radgrid to then look like the one they have here once you click on the 'Group by expression' button:

Instead, it looks like this:

After Load

Only looking right after I click the 'sort' button:

After Clicking Sort

Any clue? I even tried invoking sort manually but that was not successful.
Pavlina
Telerik team
 answered on 10 Aug 2009
6 answers
591 views
Hi there:

I have a RadGrid with 2 simple columns: one is BOUND and the other one is TEMPLATED.  Inside the Templated column, I have a label control.

Say, I want to change the backgound color of the BOUND control (different colors for different rows. Let's say, red, yellow, green and recycle them) and I want to change the innerHTML of the label control inside the Templated column to something different every row (say, A, B, C and recycle them). 

Furthermore, I want to achieve this using ClientEvents OnRowCreated. How can I achieve that? 

Of course, I know that the above can be easily done with server-side codes, however, I'm just learning how to use this new control and I want to understand the capacity of the OnRowCreated client event and I seem not to be able to find any document that explains how I can achieve the above-mentioned effect using OnRowCreated. . .

Thanks for you help!

Justin
Georgi Krustev
Telerik team
 answered on 10 Aug 2009
1 answer
169 views
Hello,
        I am using RadControls for ASPNET AJAX Q1 2009. 
I am having a RadGrid with filters on different fields. For all filters I am using RadComboBox.
I have referes to the method given for FilterTemplates example for using RadComboBox as filters.
One of the RadGrid column is displaying the Date of record.
But I have to filter this date according to Year only. 
For Ex: If I have 10 dates of year 2005 and 3 dates of 2006. Then the filter combo for date should contain items as 2005 and 2006.
         Hence whenever I select 2005 from filter it should display all dates from year 2005 along with other filters if applicable.

But now I am unable to show the year in RadComboBox filter. Also I am not able to filter on Year.

Please help me regarding this if anyone finds any solution. This is very urgent.

Thanks,
Pinkey
Yavor
Telerik team
 answered on 10 Aug 2009
3 answers
180 views
Hi

This is what I want to acomplish.

1. when i click b1 (postback p1) only p1 to update

2. when i click b2 (postback p2) only p2 and p3 to update

here is the code and why it's not working correct?

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %> 
 
<!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></title>  
</head> 
<body> 
    <form id="form1" runat="server">  
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager> 
    <div> 
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
       <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="p1">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="p1" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
            <telerik:AjaxSetting AjaxControlID="p2">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="p2" /> 
                    <telerik:AjaxUpdatedControl ControlID="p3" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
        </telerik:RadAjaxManager> 
          
        <asp:Panel ID="p1" runat="server">  
            <%= DateTime.Now.ToString() %> 
            <asp:Button ID="b1" runat="server" Text="b1" /> 
        </asp:Panel> 
          
        <asp:Panel ID="p2" runat="server">  
            <%= DateTime.Now.ToString() %> 
            <asp:Button ID="b2" runat="server" Text="b2" /> 
        </asp:Panel> 
 
        <asp:Panel ID="p3" runat="server">  
            <%= DateTime.Now.ToString() %> 
        </asp:Panel> 
 
          
    </div> 
    </form> 
</body> 
</html> 
 
Pavlina
Telerik team
 answered on 10 Aug 2009
3 answers
231 views
Hello Telerik,

The environment:
- I created a form with a RadGrid with 3 levels
- The third level (the question) has a user control that has a RadioButtonList
- The second level (the sub-section) has a RadioButtonList that looks like the other one, to change the value of all the radios in this sub-section
- The first level (the section) just shows the titles
- Screen shot: Here
- The form used has 53 controls, each one of them has a RadioButtonList with 6 options, a RadTextBox and a HiddenField. They are divided in 18 sections, and the header of those sections has also a RadioButtonList with 6 options each. That's a total of 71 RadioBoxLists and 426 radios.

Now, the problem:

- When clicking in any radio in the third level, the CPU of the client goes to 100% for around 1 second. With a slower computer, it goes up to 3 seconds.
- When clicking the radio in the sub-section, it takes a real long time to change the indexes from the inside radios. In a good client computer, around 10 seconds, and up to 30 seconds in a slower one. The following JavaScript function is used:
 
            function ChangeChildScores(QuestionID, ItemIndex, OwnerTableViewID) { 
                var OwnerTableView = document.getElementById(OwnerTableViewID); // The whole table 
                var parentTable = OwnerTableView.getElementsByTagName('table')[ItemIndex]; // The table with the questions 
                var TRs = parentTable.getElementsByTagName('tr'); // TR for each question 
                for (var r = 0; r < TRs.length; r++) { 
                    var inputs = TRs[r].getElementsByTagName('input'); // Radio boxes 
                    for (var i = 0; i < inputs.length; i++) { 
                        if (inputs[i].type == 'radio' && inputs[i].value == QuestionID) { // Checking the radio if the ID is correct 
                            inputs[i].checked = true
                        } 
                    } 
                } 
            } 
- It is much faster when using Firefox than Internet Explorer, but Firefox is still really slow.

Finally, the questions:
- Is it possible to improve the performance, or should I just forget using the form decorator?
- The decorator is in my master page. Is it possible to turn it off for a single section?

Thank you very much,
Daniel Schiavini
Martin
Telerik team
 answered on 10 Aug 2009
1 answer
157 views
Hello,

I have read a few threads in this regards but have not yet got my code working for cascading radcombo in edit mode in radgrid!

Here is my code in aspx page:

 

<telerik:RadGrid ID="gv_Users" runat="server" AutoGenerateColumns="False" GridLines="None" Height="100%" Width="100%" AllowPaging="True" AllowSorting="True" PageSize="15" OnNeedDataSource="gv_Users_NeedDataSource" OnItemCreated="gv_Users_ItemCreated" OnItemDataBound="gv_Users_ItemDataBound">

 

 

<MasterTableView DataKeyNames="UserID,ConID,RoleID,Container_Name,Role_Name">

 

 

<ExpandCollapseColumn Visible="False">

 

 

<HeaderStyle Width="19px" />

 

 

</ExpandCollapseColumn>

 

 

<RowIndicatorColumn Visible="False">

 

 

<HeaderStyle Width="20px" />

 

 

</RowIndicatorColumn>

 

 

<Columns>

 

 

<telerik:GridTemplateColumn UniqueName="col_Edit">

 

 

<HeaderStyle Width="50px" />

 

 

<ItemTemplate>

 

 

<span style="white-space: nowrap;">

 

 

<asp:ImageButton ID="btnEdit" runat="server" meta:resourceKey="btnRole_Edit" CommandName="edit" ToolTip="Edit" SkinID="ImgBtnEdit" />

 

 

<asp:ImageButton ID="btnDelete" runat="server" meta:resourceKey="btnRole_Delete" CommandName="remove" ToolTip="Delete" SkinID="ImgBtnDelete" OnClientClick="return confirm_action('Continue with delete? \nContinuer avec la suppression?');" Visible="false" /></span>

 

 

</ItemTemplate>

 

 

<ItemStyle Width="50px" />

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridDropDownColumn UniqueName="ddContainerEdit" ListTextField="Container_Name" ListValueField="Container_Name" DataField="Container_Name" HeaderText="Container_Name" DropDownControlType="RadComboBox" />

 

 

<telerik:GridDropDownColumn UniqueName="ddRoleEdit" ListTextField="Role_Name" ListValueField="Role_Name" DataField="Role_Name" HeaderText="Role_Name" DropDownControlType="RadComboBox" />

 

 

<telerik:GridBoundColumn DataField="UserID" DataType="System.Guid" HeaderText="UserID" UniqueName="col_UserID" meta:resourceKey="col_UserID" SortExpression="UserID" Visible="False">
.......

And here is my code behind page code:

 

 

Protected Sub gv_Users_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles gv_Users.ItemCreated

 

 

If (TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode) Then

 

 

 

 

 

'the combobox will be the first control in the Controls collection of the corresponding cell

 

 

 

 

 

 

 

 

Dim list As RadComboBox= CType(CType(e.Item, GridEditableItem)("ddContainerEdit").Controls(0), RadComboBox)

 

 

'attach SelectedIndexChanged event for the combobox control

 

 

 

 

list.AutoPostBack =

True

 

 

 

 

 

AddHandler list.SelectedIndexChanged, AddressOf Me.ddContainerEdit_SelectedIndexChanged

 

 

End If

 

 

 

 

 

End Sub

 

 

 

 
My error message:
Unable to cast object of type 'System.Web.UI.WebControls.Literal' to type 'Telerik.Web.UI.RadComboBox'.
I have tried changing the index in Controls(0) from 0 to 3 but it still gives me the same above error.

When I try index 4, My error message:
Specified argument was out of the range of valid values. Parameter name: index

Can you help?

Thanks,
Sanjay


Princy
Top achievements
Rank 2
 answered on 10 Aug 2009
6 answers
415 views
I need a little direction here. 

I open a RadWindow from my main page.  Inside the RadWindow I have a button called "Upload".  When clicked, I want to open a second RadWindow.  However, I'm stuck right now because what should open as a second RadWindow is actually replacing the content of the first RadWindow.

How can I solve this problem?  Comments would be appreciated!

Michael
Georgi Tunev
Telerik team
 answered on 10 Aug 2009
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?