Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
203 views
Hi,

I have a dynamically created RadGrid. Now on expanding the child tables in the Grid, I want to get the name of the tableView on "grv_ItemCommand" event. Here is my code:
private void BindData()
        {
            clickedType = Session["type"].ToString();
            int id = ParentEntity.ParentEntityId;
            GridTableView tableView = new GridTableView(grv);
 
            switch (clickedType)
            {
                case "All Categories":
                    using (SpaceCategoriesService.SpaceCategoriesServiceClient s = new SpaceCategoriesService.SpaceCategoriesServiceClient())
                    {
                        grv.DataSource = s.GetCategoryTable();
                        tableView.Name = "Buildings";
                        tableView.DataMember = "Buildings";
                    }
                    break;
 
                case "SpaceCategories":
                    using (SpaceBuildingsService.SpaceBuildingsServiceClient s = new SpaceBuildingsService.SpaceBuildingsServiceClient())
                    {
                        grv.DataSource = s.GetBuildingByCategoryId(id);
                        tableView.Name = "Floors";
                        tableView.DataMember = "Floors";
                    }
                    break;
 
                case "SpaceBuildings":
                    using (SpaceFloorService.SpaceFloorServiceClient s = new SpaceFloorService.SpaceFloorServiceClient())
                    {
                        grv.DataSource = s.GetFloorsByBuildingId(id);
                        tableView.Name = "Rooms";
                        tableView.DataMember = "Rooms";
                    }
                    break;
 
                case "SpaceFloors":
                    using (SpaceRoomService.SpaceRoomServiceClient s = new SpaceRoomService.SpaceRoomServiceClient())
                    {
                        grv.DataSource = s.GetRoomByFloorId(id);
                    }
                    break;
 
                default:
                    throw new Exception("Unable to identify Entity.");
            }
 
            grv.MasterTableView.DetailTables.Clear();
            grv.MasterTableView.DetailTables.Add(tableView);
 
            GridTableView tab = new GridTableView(grv);
            switch (tableView.Name)
            {
                case "Buildings":
                    tab.DataMember = "Floors";
                    tab.Name = "Floors";
                    tableView.DetailTables.Clear();
                    tableView.DetailTables.Add(tab);
                    break;
 
                case "Floors":
                    tab.DataMember = "Rooms";
                    tab.Name = "Rooms";
                    tableView.DetailTables.Clear();
                    tableView.DetailTables.Add(tab);
                    break;
 
                default:
                    break;
            }
 
            if (tableView.Name == "Buildings")
            {
                GridTableView subTab = new GridTableView(grv);
                if (tab.Name == "Floors")
                {
                    subTab.DataMember = "Rooms";
                    subTab.Name = "Rooms";
                    tab.DetailTables.Clear();
                    tab.DetailTables.Add(subTab);
                }
 
            }
 
            grv.DataBind();
        }
 
protected void grv_ItemCommand(object sender, GridCommandEventArgs e)
        {
            BindDetails(ParentEntity.ParentEntityId);
            HttpContext.Current.Session["id"] = ParentEntity.ParentEntityId;
            switch (Session["type"].ToString())
            {
                case "All Categories":
                    FormExtenderControl1.EntityType = new BaseEntities(BaseEntities.SpaceCategories);
                    break;
 
                case "SpaceCategories":
                    FormExtenderControl1.EntityType = new BaseEntities(BaseEntities.SpaceBuildings);
                    break;
 
                case "SpaceBuildings":
                    FormExtenderControl1.EntityType = new BaseEntities(BaseEntities.SpaceFloors);
                    break;
 
                case "SpaceFloors":
                    FormExtenderControl1.EntityType = new BaseEntities(BaseEntities.SpaceRooms);
                    break;
 
                default:
                    throw new Exception("Unable to identify Entity.");
            }
 
            clickedType = Session["type"].ToString();
 
            if (e.CommandName == "Modify")
            {
                btnSave.CommandName = "Modify";
                int id = GetID();
                FormExtenderControl1.EntityPrimaryKeyId = id;
                FormExtenderControl1.DataBind();
                mdlPopup.Show();
            }
 
            if (e.CommandName == "Delete")
            {
                int id = GetID();
                FormExtenderControl1.Delete(id);
                BindData();
            }
 
            if (e.CommandName == "Add")
            {
                btnSave.CommandName = "Add";
                FormExtenderControl1.EntityPrimaryKeyId = -1;
                FormExtenderControl1.DataBind();
                mdlPopup.Show();
            }
        }
 
        private Int32 GetID()
        {
             
            foreach (GridDataItem dataItem in grv.MasterTableView.DetailTables.OwnerGrid.Items)
            {
                 
                if (dataItem.Selected == true)
                {
                    Int32 ID = Int32.Parse(dataItem["Id"].Text);
                    return ID;
                }
            }
                        
            throw new ArgumentNullException("Id Not found");
        }
Please assist me....


thanks
Rohan
Rohan
Top achievements
Rank 1
 answered on 20 Jan 2011
2 answers
86 views
Here is the code that worked previously and is throwing an exception now.  Its purpose is to set the column header based on a datasets caption property.  I think I went from Q1 2010 to current.  I will also show some strange debug watch results.

Private Sub RadGrid_ColumnCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridColumnCreatedEventArgs) Handles RadGrid.ColumnCreated
    Dim field As String
    Try
        field = e.Column.HeaderText
        If Not field = Nothing And field <> "" Then
            If DataSet.Tables(TableName).Columns(field).ColumnName = "ID" Then
                'e.Column.Display = False ' this causes some strange formatting problems
            ElseIf DataSet.Tables(TableName).Columns(field).Caption() = _
                DataSet.Tables(TableName).Columns(field).ColumnName Then
                e.Column.Visible = False
            Else
                e.Column.HeaderText = DataSet.Tables(TableName).Columns(field).Caption()
                e.Column.HeaderStyle.Wrap = False
            End If
        End If
    Catch ex As Exception
    End Try
End Sub

The exception is being caught when trying to evaluate:DataSet.Tables(TableName).Columns(field).ColumnName

Here are the watch results on one of the passes.  The field xx_tablename is expected.  I am setting field = e.Column.HeaderText early on. 
DataSet.Tables(TableName).Columns(0).ColumnName xx_tablename String
e.Column.HeaderText xx_ tablename String
DataSet.Tables(TableName).Columns("xx_tablename").ColumnName xx_tablename String
field xx_ tablename String
DataSet.Tables(TableName).Columns(field).ColumnName Referenced object 'Item' has a value of 'Nothing'.
ex.message Object reference not set to an instance of an object. String

If I hard code variable field to "xx_tablename" in the beginning it does not error out and I get the result I want.
Kent
Top achievements
Rank 1
 answered on 20 Jan 2011
6 answers
98 views
Currently I am looking for another rich text editor to replace the default one in WSS 3 and I came across radeditor!

When the comparison chart for Native MS Editor for MOSS vs Telerik RadEditor Lite for ASP.Net showing both can and cannot do exactly the same stuff, so what is the purpose of using Telerik RadEditor Lite then?  Or did I miss out something? Pardon a novice like me if that's the case  :~)
(http://www.telerik.com/documents/RadEditorMOSS_Feature_Comparison.pdf)

Hope to get any suggestion or advice from you guys, thanks.

Michelle

Michelle
Top achievements
Rank 1
 answered on 20 Jan 2011
6 answers
129 views
Hello;
I have a SharePoint site provisioning process that creates a site from a particular template and adds (imports) webparts to that site.  None of the webparts or the entire site provisioning process uses any Telerik.  I recently deployed rad editor to my SharePoint web application.  Ever since then the site provisioning process breaks.  In particular it breaks when i'm trying to read any dwp file before i import it to the page using the splimitedwebpartmanager.Importwebpart.. method.  '

As soon as i remove the safe controls lines from the web config, the site provisioning process works again.

Why is this happening?


thanks
Charles

 
Charles Faramarzi-rad
Top achievements
Rank 1
 answered on 20 Jan 2011
2 answers
98 views
Hello
I'm trying to automate a combobox selection from a different frame then the one that contains the control.
For standard HTML controls just write parent.rightFrame.document.getElementbyId.....
However whem I try parent.rightFrame.document.$find("<%=  radcombobox.ClientID %>") I get an error saying that object doesn't suppot this method.
I'm not at all familiar with the radcontrols and i;m not sure I'm doing this right. I got the control ID from the following html element:
<div class="RadComboBox RadComboBox_WebBlue" id="ctl00_CPH1_GridView1_gvReceivingTransactions_ctl03_gvSkidWeights_ctl02_ddlLocation" >  and i tried:

var tbLocation = parent.rightFrame.document.$find("<%= ctl00_CPH1_GridView1_gvReceivingTransactions_ctl03_gvSkidWeights_ctl02_ddlLocation.ClientID %>");

Is my syntax incorrect or is the problem that I'm accesing the control from a different frame. If that's the problem what can I do to work around it?

Thanx. I Hope someone can help me.
alan
Top achievements
Rank 1
 answered on 19 Jan 2011
10 answers
762 views
I may be wrong but it seems to me that the only way to populate a drop down column in a grid is with databinding. Is there a way to poopulate the items as follows:

combobox.items.add("First Item");
combobox.items.add("Second Item");
etc.

I don't need to populate from tables for each drop down column.

Regards, Lee
Lee
Top achievements
Rank 1
 answered on 19 Jan 2011
1 answer
70 views
Hi!
I'm having a problem with the templateColumn. I can have a merged header, but for some reason, there's no way I can edit the value of the items under that column. I've been reading as many post as I could, but no answer so far.
I've tried different approaches, but the last best I could do was this:


<telerik:RadGrid ID="RadGrid1" EnableAJAX="True" ShowStatusBar="true" runat="server" Skin="Default" BorderColor="#97A222"  Width="95%"
            AutoGenerateColumns="False" PageSize="16" AllowSorting="True" AllowMultiRowSelection="False"
            AllowAutomaticDeletes="True" AllowAutomaticUpdates="True"
            AllowPaging="False" AllowScroll = "True" GridLines="None" OnDetailTableDataBind="RadGrid1_DetailTableDataBind" OnNeedDataSource="RadGrid1_NeedDataSource">
             
            <MasterTableView Width="100%" DataKeyNames="Name" AllowMultiColumnSorting="True">
                <DetailTables>
                    <telerik:GridTableView DataKeyNames="Name" DataMember="Details" Width="100%" GridLines="Horizontal"
                       AllowAutomaticDeletes="True" AllowAutomaticUpdates="True"
                        Style="border-color: #d5b96a" CssClass="RadGrid2">
                        <Columns>
                                
                               <telerik:GridEditCommandColumn UpdateText="Update" UniqueName="EditCommandColumn" CancelText="Cancel"
                                EditText="Edit">
                              <HeaderStyle Width="85px"></HeaderStyle>
                             
                            </telerik:GridEditCommandColumn>
                            <telerik:GridBoundColumn SortExpression="Name" HeaderText="Name" ReadOnly = "True" HeaderButtonType="TextButton"
                                DataField="Name">
                            </telerik:GridBoundColumn>
                            <telerik:GridTemplateColumn UniqueName="TemplateColumn">
                              <HeaderTemplate>
                               <table id="Table1" cellspacing="1" cellpadding="1" width="300" border="1">
                                <tr>
                                 <td colspan="2" align="center"><b>Revenue Growth Strategy</b></TD>
                                </tr>
                                <tr>
                                 <td width="50%"><b>Drive organic growth</b></TD>
                                 <td width="50%"><b>Global expansion</b></TD>
                                </TR>
                               </TABLE>
                              </HeaderTemplate>
                              <ItemTemplate>
                               <table id="Table2" cellspacing="1" cellpadding="1" width="300" border="1">
                                <tr>
                                 <td width="50%"><%# DataBinder.Eval(Container.DataItem , "Drive organic growth")%></TD>
                                 <td width="50%"><%# DataBinder.Eval(Container.DataItem, "Global expansion")%></TD>
                                </tr>
                               </table>
                              </ItemTemplate>
                           </telerik:GridTemplateColumn>
                             
                            <telerik:GridBoundColumn SortExpression="Drive organic growth" HeaderText="Drive organic growth" HeaderButtonType="TextButton"
                                DataField="Drive organic growth">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn SortExpression="Global expansion" HeaderText="Global expansion" HeaderButtonType="TextButton"
                                DataField="Global expansion">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn SortExpression="Market new products and services" HeaderText="Market new products and services" HeaderButtonType="TextButton"
                                DataField="Market new products and services">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn SortExpression="Operational improvement" HeaderText="Operational improvement" HeaderButtonType="TextButton"
                                DataField="Operational improvement">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn SortExpression="Technology initiatives" HeaderText="Technology initiatives" HeaderButtonType="TextButton"
                                DataField="Technology initiatives">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn SortExpression="Customer convenience" HeaderText="Customer convenience" HeaderButtonType="TextButton"
                                DataField="Customer convenience">
                            </telerik:GridBoundColumn>
                        </Columns>
                    </telerik:GridTableView>
                </DetailTables>
                <Columns>
                    <telerik:GridBoundColumn SortExpression="Name" HeaderText="Name" HeaderButtonType="TextButton"
                        DataField="Name">
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>


I'll appreciate any help.
Daniel
Top achievements
Rank 1
 answered on 19 Jan 2011
20 answers
516 views

When creating an custom DataFieldEditor an error is thrown upon postback.
The custom class looks like (same implementation as the RadFilterTextFieldEditor)

Public Class RadFilterMyTextFieldEditor  
    Inherits RadFilterDataFieldEditor  
 
    Protected Overrides Sub CopySettings(ByVal baseEditor As RadFilterDataFieldEditor)  
        MyBase.CopySettings(baseEditor)  
        Dim editor As RadFilterTextFieldEditor = TryCast(baseEditor, RadFilterTextFieldEditor)  
        If (Not editor Is Nothing) Then  
            Me.TextBoxWidth = editor.TextBoxWidth  
        End If  
    End Sub  
 
    Public Overrides Function ExtractValues() As ArrayList  
        Dim list As New ArrayList  
        list.Add(Me._textBoxControl.Text)  
        If Not MyBase.IsSingleValue Then  
            list.Add(Me._secondTextBoxControl.Text)  
        End If  
        Return list  
    End Function  
 
    Public Overrides Sub InitializeEditor(ByVal container As Control)  
        Me._textBoxControl = New TextBox  
        Me._textBoxControl.CssClass = "rfText" 
        Me._textBoxControl.Width = Unit.Pixel(Me.TextBoxWidth)  
        container.Controls.Add(Me._textBoxControl)  
        If Not MyBase.IsSingleValue Then  
            MyBase.AddBetweenDelimeterControl(container)  
            Me._secondTextBoxControl = New TextBox  
            Me._secondTextBoxControl.CssClass = ("rfText")  
            Me._secondTextBoxControl.Width = Unit.Pixel(Me.TextBoxWidth)  
            container.Controls.Add(Me._secondTextBoxControl)  
        End If  
    End Sub  
 
    Public Overrides Sub SetEditorValues(ByVal values As ArrayList)  
        If (Not values Is Nothing) Then  
            If (Not values.Item(0) Is Nothing) Then  
                Me._textBoxControl.Text = (values.Item(0).ToString)  
            End If  
            If (Not MyBase.IsSingleValue AndAlso (Not values.Item(1) Is Nothing)) Then  
                Me._secondTextBoxControl.Text = values.Item(1).ToString  
            End If  
        End If  
    End Sub  
 
    <DefaultValue("120"), NotifyParentProperty(True)> _  
    Public Property TextBoxWidth() As Integer  
        Get  
            Dim obj2 As Object = MyBase.ViewState.Item("TextBoxWidth")  
            If (obj2 Is Nothing) Then  
                Return 120  
            End If  
            Return CInt(obj2)  
        End Get  
        Set(ByVal value As Integer)  
            MyBase.ViewState.Item("TextBoxWidth") = value  
        End Set  
    End Property  
 
    ' Fields  
    Private _secondTextBoxControl As TextBox  
    Private _textBoxControl As TextBox  
 
End Class 

When using this on a web form like

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init  
 
        Dim oMyTextFilter As New RadFilterMyTextFieldEditor  
        oMyTextFilter.FieldName = "Company" 
 
        RadFilter1.FieldEditors.Add(oMyTextFilter)  
 
    End Sub  
 

The following error is thrown upon postback

Exception Details: System.ArgumentNullException: Value cannot be null.  
Parameter name: item  
 
Source Error:   
 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.    
 
Stack Trace:   
 
 
[ArgumentNullException: Value cannot be null.  
Parameter name: item]  
   Telerik.Web.UI.RadFilterDataFieldEditorCollection.InsertInternal(Int32 index, RadFilterDataFieldEditor item) +77  
   Telerik.Web.UI.RadFilterDataFieldEditorCollection.Add(RadFilterDataFieldEditor item) +40  
   Telerik.Web.UI.RadFilterDataFieldEditorCollection.System.Web.UI.IStateManager.LoadViewState(Object state) +602  
   Telerik.Web.UI.RadFilter.LoadViewState(Object savedState) +155  
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +183  
   System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134  
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221  
   System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134  
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221  
   System.Web.UI.Page.LoadAllState() +312  
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1661  
 
   
 

What goes wrong?
My intention is to create a custom editor with dropdown list boxes in stead of the regular text edits


Steve McManamam
Top achievements
Rank 1
 answered on 19 Jan 2011
9 answers
464 views
Code in aspx:

<asp:UpdatePanel ID="upComboBox" runat="server">  
                <ContentTemplate> 
                    <telerik:RadComboBox ID="rcb" runat="server" SkinID="Larger" Height="200px">  
                        <ItemTemplate> 
                            <telerik:RadTreeView ID="rtv" runat="server" OnNodeClick="rtv_NodeClick" 
                                CausesValidation="false">  
                            </telerik:RadTreeView> 
                        </ItemTemplate> 
                        <Items> 
                            <telerik:RadComboBoxItem Selected="true" /> 
                        </Items> 
                    </telerik:RadComboBox> 
                </ContentTemplate> 
</asp:UpdatePanel> 


  Code in aspx.cs

 protected void rtv_NodeClick(object sender, RadTreeNodeEventArgs e)  
 {  
     rcb.Items[0].Value = e.Node.Value;  
     rcb.Items[0].Text = e.Node.Text;  
 }  

This method won't stop whole page postback when you trigger the rtv_NodeClick event

There somebody said, should put the updatepanel inside ComboBox like follows
  <telerik:RadComboBox ID="rcbConsigned" runat="server" SkinID="Larger" Height="200px">  
                        <ItemTemplate> 
                            <asp:UpdatePanel ID="up" runat="server">  
                                <ContentTemplate> 
                                    <telerik:RadTreeView ID="rtvSubcon" runat="server" OnNodeClick="rtvSubcon_NodeClick" 
                                        CausesValidation="false">  
                                    </telerik:RadTreeView> 
                                </ContentTemplate> 
                            </asp:UpdatePanel> 
                        </ItemTemplate> 
                        <Items> 
                            <telerik:RadComboBoxItem Selected="true" /> 
                        </Items> 
                    </telerik:RadComboBox> 
This method can stop the whole page postback, but as ajax method, it won't change the value of radcombox.

As we were told ms-help://telerik.aspnetajax.radcontrols.2009.Q1/telerik.aspnetajax.radajax.2009.Q1/3rdparty.html

Controls that Are Not Compatible with RadAjaxManager Control

The following ASP.NET controls are not compatible with partial-page updates, and are therefore not supported as initiating or updated controls:



 
Simon
Telerik team
 answered on 19 Jan 2011
1 answer
79 views
Do you have good example of RadUpload controls inside Formview Control with server side API?
When i upload file , i can find the control but when i save i could not find posted file.

Thanks,
Dimitar Terziev
Telerik team
 answered on 19 Jan 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?