Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
113 views

Hi,
I have a question regarding GridDropDownColumn

In a Grid, i want the field prodtype to be a dropdown, where i can pick a value from ANOTHER table, when i update
or insert in the grid.

I know i can do it like this, but in this example, the values come from the same table as the grid is build on:

<telerik:GridDropDownColumn
 DataSourceID="SqlDataSource1"
 ListTextField="prodtype" ListValueField="prodtype"
 UniqueName="prodtype" SortExpression="prodtype"
 HeaderText="prodtype" DataField="prodtype">
</telerik:GridDropDownColumn>

Hope i can do it without any code.

Br
Gert Petersen

Gert Petersen
Top achievements
Rank 1
 answered on 08 Apr 2010
1 answer
91 views
Hello, I have a grid and a checked listbox, what I want to do is filter de grid by selecting/deselecting the listbox items, i had it working, but I don't know why it stopped working, this is the code:

private void fncGridData(){  
        try 
        { 
            DataView dvDataView=new DataView(); 
            dvDataView = ((DataTable)Cache["Materials"]).DefaultView; 
            if (lstSubcategories.CheckedItems.Count == lstSubcategories.Items.Count) 
            { 
                dvDataView.RowFilter = ""; 
            } 
            else if(lstSubcategories.CheckedItems.Count==0){ 
                dvDataView.RowFilter = "id_sub_category=-1"; 
            } 
            else { 
                dvDataView.RowFilter = "id_sub_category IN (" + fncQueryComplement() + ")"; 
            } 
            RadGrid1.DataSource = (DataTable)Cache["Materials"]; 
        } 
        finally 
        {     
            SqlConnection.Close(); 
        } 
    } 

This code was exceuted on the ItemCheck property of the listbox, but then I made some changes to other parts of the code and it stopped working, why is this?

Regards.


Yavor
Telerik team
 answered on 08 Apr 2010
1 answer
126 views
I have looked at several posts in the forum regarding filtering.  I want to achieve the following objective:

  • On load if there is no filter value (populated from state) the filter row is hidden and the filter button in the command toolbar is toggled off
  • On load if there is a filter value (populated from state) the filter row is show and the filter button in the command toolbar is toggled on
  • If the filter button is toggled on, show the filter row (preferably on client-side rather than AJAX round trip)
  • If the filter button is toggled off, clear all filters, hide the filter row, and rebind the grid

I have been able to manage the display of the filter row using the ItemCreated event:
if (e.Item is GridFilteringItem && string.IsNullOrEmpty(Grid.MasterTableView.FilterExpression)) 
{ 
    e.Item.Display = false; 
} 
else if (e.Item is GridCommandItem && !string.IsNullOrEmpty(Grid.MasterTableView.FilterExpression)) 
{ 
    var toolBar = e.Item.FindControl("ToolBar") as RadToolBar; 
    (toolBar.FindButtonByCommandName("Filter") as RadToolBarButton).Checked = true; 
} 

On the client side it sort-of works, but there is some odd behavior:
function ToolBar_ClientButtonClicked(sender, args) 
{ 
    var button = args.get_item(); 
    switch (button.get_commandName()) 
    { 
        case 'Filter': 
            if (button.get_isChecked()) 
            { 
                $find('<%= Grid.ClientID %>').get_masterTableView().showFilterItem(); 
            } 
            else 
            { 
                var masterTableView = $find("<%= Grid.ClientID %>").get_masterTableView(); 
                masterTableView.filter("Description", "", Telerik.Web.UI.GridFilterFunction.NoFilter); 
                masterTableView.filter("Class", "", Telerik.Web.UI.GridFilterFunction.NoFilter); 
                masterTableView.filter("DefaultCategory", "", Telerik.Web.UI.GridFilterFunction.NoFilter); 
                masterTableView.hideFilterItem(); 
            } 
            break; 
    } 
} 

I have to click the filter button three times to get it to show the row (turn on, turn off, turn on and then I see the row).  If I use jQuery to hide the .rgFilterRow class it works fine.

The calls to clear the filter appear to generate individual post-backs where I want one call to clear everything.  One thought was to use fireCommand and do the clean-up on the server side.  In either case I also want to only make the callback if the filter has a value in it (if the results aren't currently filtered there is no point in round tripping).

Thoughts?
Yavor
Telerik team
 answered on 08 Apr 2010
1 answer
143 views
Hello,

Scenario: User selected an item then scrolled the grid.

In order to find selected item fast, I would like to put a button that says "Bring into view" so the grid can show me the selected item.

1. Is there a way to do that ?
2. Is there a way to get the first / last visible item ?
Shinu
Top achievements
Rank 2
 answered on 08 Apr 2010
4 answers
166 views

Hi,

I need to create hierarchical rad grid programatically using DataTable, but I'm having a problem in settng the data source for level 1 hierarchy. When I try to expand the child table, an exception is thrown as
 
"Exception Details: System.Data.SyntaxErrorException: Syntax error: Missing operand before 'Is' operator."

Kindly help me out regarding this issue. I have attached my code and exception trace. Thanks

Regards
Muhammad Farjad

----------------------------------------------------------------------------------------------------------------------------------------------------------------------

<body>

 

     <form id="form1" runat="server">

 

         <telerik:RadScriptManager ID="RadScriptManager1" runat="server">

 

             <Scripts>

 

                 <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />

 

                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />

 

             </Scripts> 
        
</telerik:RadScriptManager>

 

        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">

         </telerik:RadAjaxManager>

 

        <div>

 

             <telerik:RadGrid ID="RadGrid1" runat="server" ondetailtabledatabind="RadGrid1_DetailTableDataBind">

 

              </telerik:RadGrid>

         </div>

 

    </form>

 </body>

---------------------------------------------------- Code Behind File ----------------------------------------------------------------------------

using
System;

 

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Data;

using System.Configuration;

using System.Web.Security;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using Telerik.Web.UI;

 

public partial class Default : System.Web.UI.Page

{ 

    protected void Page_Load(object sender, EventArgs e) 
    {

         if (!IsPostBack)

         {

             //Add grand father table

             DataTable grandFatherTable = CreateDataTable("GrandFather");

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

             AddDataToTable("usman", "Usman", "Mansur", grandFatherTable);

             AddDataToTable("adnan", "Adnan", "Ahmad", grandFatherTable);

             AddDataToTable("nabeel", "Nabeel", "Ahmed", grandFatherTable);

 

              RadGrid1.DataSource = grandFatherTable;

              RadGrid1.MasterTableView.DataKeyNames = new string[] { "username" };

              RadGrid1.Width = Unit.Percentage(98);

              RadGrid1.PageSize = 5;

              RadGrid1.AllowPaging = true;

 

               //RadGrid1.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric;

               RadGrid1.AutoGenerateColumns = false;

 

 

 

 

 

 

 

 

 

 

 

 

               RadGrid1.Skin = "Web20";

 

                RadGrid1.MasterTableView.PageSize = 15;

                RadGrid1.MasterTableView.Width = Unit.Percentage(100);

                GridBoundColumn boundColumn;

                boundColumn = new GridBoundColumn();

 

                RadGrid1.MasterTableView.Columns.Add(boundColumn);

                boundColumn.DataField = "username";

                 boundColumn.HeaderText = "User Name";

                 boundColumn = new GridBoundColumn();

 

                    RadGrid1.MasterTableView.Columns.Add(boundColumn);

                    boundColumn.DataField = "firstname";

                    boundColumn.HeaderText = "First Name";

                     boundColumn = new GridBoundColumn();

 

                    RadGrid1.MasterTableView.Columns.Add(boundColumn);

                    boundColumn.DataField = "lastname";

                    boundColumn.HeaderText = "Last Name";

 

                     //Add Father table

                     DataTable fatherTable = CreateDataTable("Father");

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

                     AddDataToTable("usman", "u1", "u2", fatherTable);

                     AddDataToTable("adnan", "a1", "a2", fatherTable);

                     AddDataToTable("nabeel", "n1", "n2", fatherTable);

 

                    GridTableView tableViewFather = new GridTableView(RadGrid1);

                     tableViewFather.Width = Unit.Percentage(100);

                    tableViewFather.DataSource = fatherTable;

                    tableViewFather.DataKeyNames = new string[] { "username" };

 

                    GridRelationFields relationFields = new GridRelationFields();

                     relationFields.MasterKeyField = "username";

                     relationFields.DetailKeyField = "username";

 

                        tableViewFather.ParentTableRelation.Add(relationFields);

                        RadGrid1.MasterTableView.DetailTables.Add(tableViewFather);

                        boundColumn = new GridBoundColumn();

                        tableViewFather.Columns.Add(boundColumn);

                        boundColumn.DataField = "username";

                         boundColumn.HeaderText = "User Name";

 

                            boundColumn = new GridBoundColumn();

                             tableViewFather.Columns.Add(boundColumn);

                            boundColumn.DataField = "firstname";

                            boundColumn.HeaderText = "First Name";

                             
                            boundColumn = new GridBoundColumn();

                             tableViewFather.Columns.Add(boundColumn);

                            boundColumn.DataField = "lastname";

                             boundColumn.HeaderText ="Last Name";

        }
    }

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

    private DataTable CreateDataTable(string tableName)

     {   

            DataTable myDataTable = new DataTable(tableName);

             DataColumn myDataColumn;

             myDataColumn = new DataColumn();

             myDataColumn.DataType = Type.GetType("System.String");

 

            myDataColumn.ColumnName = "username";

 

            myDataTable.Columns.Add(myDataColumn);

            myDataColumn = new DataColumn();

            myDataColumn.DataType = Type.GetType("System.String");

             myDataColumn.ColumnName = "firstname";

             myDataTable.Columns.Add(myDataColumn);

            myDataColumn = new DataColumn();

             myDataColumn.DataType = Type.GetType("System.String");

             myDataColumn.ColumnName = "lastname";

             myDataTable.Columns.Add(myDataColumn);

             return myDataTable;

     }

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

    private void AddDataToTable(string username, string firstname, string lastname, DataTable myTable)

     {

        DataRow row;

        row = myTable.NewRow();

         //row["id"] = Guid.NewGuid().ToString();

         row["username"] = username;

 

 

 

 

         row["firstname"] = firstname;

         row["lastname"] = lastname;

         myTable.Rows.Add(row);

    }

 

 

 

 

 

 

 

    protected void RadGrid1_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e)

     {

        DataTable fatherTable = CreateDataTable("Father");

         AddDataToTable("usman", "u1", "u2", fatherTable);

         AddDataToTable("adnan", "a1", "a2", fatherTable);

         AddDataToTable("nabeel", "n1", "n2", fatherTable);

         e.DetailTableView.DataSource = fatherTable;

    }

}

 

 

 

 

 

 

 

 

 

 

 

 

---------------------------------------------------------- exception ------------------------------------------------------------------------

Server Error in '/RadHierarchicalGrid' Application.
--------------------------------------------------------------------------------

Syntax error: Missing operand before 'Is' operator.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SyntaxErrorException: Syntax error: Missing operand before 'Is' operator.

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:

[SyntaxErrorException: Syntax error: Missing operand before 'Is' operator.]
   System.Data.ExpressionParser.Parse() +4824040
   System.Data.DataExpression..ctor(DataTable table, String expression, Type type) +121
   System.Data.DataView.set_RowFilter(String value) +153
   System.Data.LinqDataView.set_RowFilter(String value) +53
   Telerik.Web.UI.GridEnumerableFromDataView.PerformTransformation() +375
   Telerik.Web.UI.GridEnumerableFromDataView.TransformEnumerable() +21
   Telerik.Web.UI.GridTableView.GetEnumerator(Boolean useDataSource, GridEnumerableBase resolvedDataSource, ArrayList dataKeysArray) +105
   Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource) +432
   Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +500
   System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +57
   System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +114
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +31
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +142
   Telerik.Web.UI.GridTableView.PerformSelect() +4
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73
   Telerik.Web.UI.GridTableView.DataBind() +224
   Telerik.Web.UI.GridDataItem.OnExpand() +272
   Telerik.Web.UI.GridItem.set_Expanded(Boolean value) +109
   Telerik.Web.UI.GridExpandCommandEventArgs.ExecuteCommand(Object source) +34
   Telerik.Web.UI.RadGrid.OnBubbleEvent(Object source, EventArgs e) +134
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e) +115
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +118
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +166
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

 

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927

Muhammad Farjad
Top achievements
Rank 1
 answered on 08 Apr 2010
1 answer
396 views
Hi, I want to use the file explorer as a file selector control in a sharepoint web part.  In other words, the user needs to select a file so that I know which file to process for him, and they will do that using the file explorer.

I have implemented a file browser content provider already, similar to Stoyan Stratev's content provider, and now I need to get the selected file information from the file explorer itself.  Can someone explain how to get the selected file information from the file explorer control?

Thanks!
Tomas
Top achievements
Rank 1
 answered on 08 Apr 2010
2 answers
140 views
I have 2 radcombobox in radgrid  , radcombobox A and radcombobox B.
The the grid is in add record mode in some situation , radcombobox B content are based on the selection on radcombobox A.

My problem is under the situation where the radcombobox B is not bind to any data, i can't find the radcombobox B by the coding below:
radCombo2 = CType(editItem.FindControl("ddlModuleParentGC"), RadComboBox)radCombo2 = CType(editItem.FindControl("ddlModuleParentGC"), RadComboBox)

My question is as below:
(1).Since the radcombobox B content is based on selection on  radcombobox A , does anyone know how to bind the data to the radcombobox B when the radgrid first go into add record mode? I think this will solve the problem.Pls correct me if i am wrong.

(2) My coding is as below
RadComboBox A=ddlAppID
RadComboBox B= ddlModuleParentGC


Public Sub BindSecondCombo(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) 
 
        Dim radCombo1 As RadComboBox 
        Dim radCombo2 As RadComboBox 
        Dim editItem As GridDataInsertItem 
 
 
        radCombo1 = CType(sender, RadComboBox) 
        editItem = CType(radCombo1.NamingContainer, GridDataInsertItem) 
 
 
 
        radCombo2 = CType(editItem.FindControl("ddlModuleParentGC"), RadComboBox) 
 
        If radCombo2 Is Nothing = False Then 
            radCombo2.ClearSelection() 
            radCombo2.DataSource = getRecordByType(7, radCombo1.SelectedValue, "", "", "", "", "") 
            radCombo2.DataTextField = "modulename" 
            radCombo2.DataValueField = "moduleid" 
            radCombo2.DataBind() 
            radCombo2.DataSource = getRecordByType(7, radCombo1.SelectedValue, "", "", "", "", "") 
            radCombo2.DataTextField = "modulename" 
            radCombo2.DataValueField = "moduleid" 
 
            radCombo2.DataBind() 
        End If 
    End Sub 


My code behind is
 <ajax:GridTemplateColumn  UniqueName="GCAppId" HeaderText="Application" SortExpression="AppId" > 
                    <HeaderStyle Width="100px" /> 
                    <ItemTemplate> 
                        <asp:Label ID="lblGCAppId" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "AppId") %>'></asp:Label> 
                    </ItemTemplate> 
                    <EditItemTemplate> 
                        <asp:Label ID="lblGCEAppId" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "AppId") %>'></asp:Label> 
                     
   
                 <ajax:RadComboBox runat="server" ID="ddlAppId" DataSource="<%# getApp() %>"  OnSelectedIndexChanged="BindSecondCombo" 
                    DataTextField="Selection"  AutoPostBack ="true" 
                    DataValueField="AppId"  
                    SelectedValue='<%# DataBinder.Eval(Container.DataItem, "AppId") %>'></ajax:RadComboBox> 
                    
                     
                     
                    </EditItemTemplate> 
                </ajax:GridTemplateColumn> 
 
  
                <ajax:GridTemplateColumn  UniqueName="GCModuleParent" HeaderText="Module Parent" SortExpression="ModuleParent" > 
                    <HeaderStyle Width="100px" /> 
                    <ItemTemplate> 
                     
                        <asp:Label ID="lblModuleParent" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ModuleParent") %>'></asp:Label> 
                    </ItemTemplate> 
                     
                    <EditItemTemplate> 
                     
                       <ajax:RadComboBox runat="server" ID="ddlModuleParentGC" ></ajax:RadComboBox> 
                    <asp:textbox ID="txtModuleParent"  runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ModuleParent") %>'></asp:textbox> 
                         
                    </EditItemTemplate> 
                </ajax:GridTemplateColumn> 






johnson lim
Top achievements
Rank 1
 answered on 07 Apr 2010
1 answer
121 views
Hi Guys,

I have searched through the forum and cannot find how to convert the date into an SQL format string.

When the date is submitted it is in the "dd-mm-yyyy hh-mm-ss" format, trouble is, SQL Server stores its dates in "yyyy-mm-dd hh-mm-ss" format.

Is there a way of converting the date to SQL server date, I dont want the display date to look like the SQL date.

Thanks in advance.
Tony Casey
Top achievements
Rank 1
 answered on 07 Apr 2010
5 answers
290 views
I am encountering an issue with changing the Height of a RadPane when using ajax. I have a splitter control with a left pane, top right pane and a bottom right pane(envision MS Outlook). The right hand panes are loaded with WebUserControls depending on the selections made in the left pane control. With ajax disabled everthing works as expected, i.e. controls are loaded and unloaded, state is maintained/saved and I am able to change the height and width of all panes and splitbars, etc... . When I enable ajax everthing still works with the exception of being able to resize the RadPanes. I have reviewed several training videos and samples over the last week, but none of them address this issue.

Your help is greatly appreciated.
Shawn
Simon
Top achievements
Rank 1
 answered on 07 Apr 2010
1 answer
142 views
Hi,

this is shanker am using GridDateTimeColumn  in rad grid.It's fine it's working but here time show 1 am and 1 pm and 9 am and 9 pm ......... just like that. But i want  0 to 23 hrs how to get that formate please send any solutions 

this is my column 
 <telerik:GridDateTimeColumn DataField="start_time" HeaderText="Start Time" SortExpression="start_time" 
                       UniqueName="start_time" DataFormatString="{0:t}" PickerType="TimePicker" 
                       DataType="System.DateTime"  > 
                    </telerik:GridDateTimeColumn> 

thanks and regards 
shanker.B 
Bruno
Top achievements
Rank 2
 answered on 07 Apr 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?