Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
128 views
I am trying to use Related Combobox  example but I am not able to get e.Text/e.Value on the server side. It is returning empty string. At the Client side item.get_value() return the correct value.

Thanks,
M P

 

 


 

Simon
Telerik team
 answered on 03 Feb 2010
1 answer
153 views
If there are multiple Rad instance Mangers, in content pages and user controls by replacing Rad Ajax Managers with Rad Ajax Manager Proxy the it would not be work. I have to change some changes in code behind file.
Is there any possibility to do the coding in Master page so that by just replacing Manager with Proxy we can acheive ajaxification.
Pavlina
Telerik team
 answered on 03 Feb 2010
1 answer
131 views
Hello all.  I'm having a problem with some quirky behavior in a RadPageView.

My page has a single RadMultiPage control, with no RadTabStrip.  The multipage is used to display a 'wizard'-like series of forms to the user.  I've placed some LinkButton controls at the bottom of each RadPageView for the user to proceed, go back, print a report, and so on.

The LinkButton controls work just fine if the form loads with the RadMultiPage control's attribute SelectedIndex set to 0.  However, I need to be able to programmatically redirect to a different RadPageView on page load, depending on where the user came from.  To accomplish this, I'm passing some parameters in the URL when the app loads this page in order to determine where to start within the wizard.  In the Page_Load() event, I look at the URL parameter and, if necessary, set the RadMultiPage's SelectedIndex to the second RadPageView.

This works great, the page loads with the second RadPageView displayed, everything's fine, except.... my LinkButtons no longer work.  The LinkButton controls at the bottom of the RadPageView no longer appear to trigger a postback.  I've tried using the OnCommand() event, I've tried switching to the OnClick() event, doesn't make a difference.  I've also tried moving where the RadMultiPage's SelectedIndex gets set - moved it to the RadMultiPage OnInit event and OnPreRender event with no change in behavior.

Am I overlooking something obvious? 
Yana
Telerik team
 answered on 03 Feb 2010
1 answer
217 views

I am using radGrid with EditMode = popup and using WebUserControl within EditFormSetting and I am utilizing RadAjaxManager  as described below
ASPX page

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="W_GridViewClass_Default2" %> 
 
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> 
 
<!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">  
    <table style="width:100%;">  
        <tr> 
            <td> 
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">  
    <Scripts> 
     <asp:ScriptReference Path="~/W_GridViewClass/jquery-1.3.2.min.js" />   
    </Scripts> 
    </telerik:RadScriptManager> 
            </td> 
        </tr> 
        <tr> 
            <td> 
                <telerik:RadAjaxManager ID="RadAjaxManager1" DefaultLoadingPanelID="RadAjaxLoadingPanel1" runat="server">  
                <AjaxSettings> 
              <telerik:AjaxSetting AjaxControlID="RadGrid1">  
                <UpdatedControls> 
              <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
                </UpdatedControls> 
                </telerik:AjaxSetting> 
                </AjaxSettings> 
                </telerik:RadAjaxManager> 
            </td> 
        </tr> 
        <tr> 
            <td> 
                <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Runat="server"   
                    Skin="Default">  
                       <img id="imgId" alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page,"Telerik.Web.UI.Skins.Default.Ajax.loading2.gif") %>' align="middle"  />Pleaase wait  
                </telerik:RadAjaxLoadingPanel> 
            </td> 
        </tr> 
        <tr> 
            <td> 
                &nbsp;</td> 
        </tr> 
        <tr> 
            <td> 
      
        <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None"   
            onneeddatasource="RadGrid1_NeedDataSource" onitemcreated="RadGrid1_ItemCreated">  
<MasterTableView autogeneratecolumns="False" EditMode="PopUp">  
<RowIndicatorColumn> 
<HeaderStyle Width="20px"></HeaderStyle> 
</RowIndicatorColumn> 
 
<ExpandCollapseColumn> 
<HeaderStyle Width="20px"></HeaderStyle> 
</ExpandCollapseColumn> 
    <Columns> 
        <telerik:GridTemplateColumn UniqueName="TemplateColumn">  
            <ItemTemplate> 
                <asp:LinkButton runat="server" CausesValidation="false" CommandName="Edit"   
                    Text="Edit"></asp:LinkButton> 
            </ItemTemplate> 
        </telerik:GridTemplateColumn> 
        <telerik:GridBoundColumn DataField="InstName" HeaderText="InstName"   
            UniqueName="column3">  
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn DataField="Address" HeaderText="Address"   
            UniqueName="column1">  
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn DataField="City" HeaderText="City"   
            UniqueName="column2">  
        </telerik:GridBoundColumn> 
    </Columns> 
      <EditFormSettings EditFormType="WebUserControl" PopUpSettings-Modal="true" CaptionFormatString="{0}" CaptionDataField="InstName">  
<PopUpSettings Modal="True" Width="750px"></PopUpSettings> 
        </EditFormSettings> 
</MasterTableView> 
        </telerik:RadGrid> 
      
            </td> 
        </tr> 
        <tr> 
            <td> 
                &nbsp;</td> 
        </tr> 
    </table> 
    <div> 
      
    </div> 
    </form> 
</body> 
</html> 
 

User Control ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs" Inherits="W_GridViewClass_WebUserControl" %> 
 
<div id="divUctrl">  
<table width="700">  
    <tr> 
        <td> 
            &nbsp;</td> 
        <td> 
            <asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">  
            <Scripts> 
            <asp:ScriptReference Path="~/W_GridViewClass/JScript.js" /> 
            </Scripts> 
            </asp:ScriptManagerProxy> 
        </td> 
        <td> 
            &nbsp;</td> 
    </tr> 
    <tr> 
        <td width="100">  
            input one&nbsp;</td> 
        <td width="200">  
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
        </td> 
        <td width="500">  
            &nbsp;</td> 
    </tr> 
    <tr> 
        <td> 
            &nbsp;</td> 
        <td> 
            &nbsp;</td> 
        <td> 
            &nbsp;</td> 
    </tr> 
</table> 
</div> 

aspx.cs
using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Web;  
using System.Web.UI;  
using System.Web.UI.WebControls;  
 
public partial class W_GridViewClass_Default2 : System.Web.UI.Page  
{  
    protected void Page_Load(object sender, EventArgs e)  
    {  
          
    }  
 
    protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)  
    {  
        RadGrid1.DataSource = ClassDB.GetInstInfo();  
    }  
    protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)  
    {  
        RadGrid1.MasterTableView.EditFormSettings.UserControlName = "WebUserControl.ascx";  
    }  
} 

Js file
$("div [id $='divUctrl']").ready(function() {  
 
    $("* [id $='TextBox1']").change(function() {  
        var test = "";  
    });  
}); 

the problem is that the Javascript file is not loaded in other way is not Synchronized when radgrid edit button fired.
when I Comment out the AjaxSetting for the RadGrid it works fine and javascript.js is loaded and  $("div [id $='divUctrl']").ready() would be fired. and the chenge event for the textbox would fire properly.

 <telerik:AjaxSetting AjaxControlID="RadGrid1">  
                <UpdatedControls> 
            <%--  <telerik:AjaxUpdatedControl ControlID="RadGrid1" />--%> 
                </UpdatedControls> 
                </telerik:AjaxSetting> 
                </AjaxSettings> 
                </telerik:RadAjaxManager> 

any help would really be Appreciated   
Pavlina
Telerik team
 answered on 03 Feb 2010
6 answers
129 views
I am experiencing an issue when using UseStaticHeaders="true". The headers do not fill the width of the grid and are therefore misaligned with the columns which are auto-sized. When clicking on a header to sort the column, the issue is resolved. TableLayout="Auto" on MasterTableView - I have tried all of the things recommended in similar posts but have not had success. The issue does not occur in Firefox, but occurs in IE 7,8
Pavlina
Telerik team
 answered on 03 Feb 2010
1 answer
105 views
Dear experts,

         I have RadGrid1 and RadGrid2, both of them synchronised (thanks to Lenny_shp).

         When I put borders in both grids, I see that RadGrid1's height is increasing while expanding the master rows : this is due to a border-width around child rows. So the more parent rows you expand and the more the radgrid1 increases in height.

         I was asked to have the both radgrids synchronised, that is : having the same height for each row in both grids.

         Is it possible to have vertical lines aligned when expanding master rows in RadGrid1 ?
         GetConnectionString() method must be changed in the code below.

     One strange thing : if I put "autogeneratecolumns = false" and add <columns> ... </columns> in RadGrid1, then I have the same height as RadGrid2. But then the problem is : the cells in RadGrid1 are not aligned when rows are expanded ... The dream is to get the both grides aligned and also the cells in RadGrid1 aligned, expanded or not ... I'm trying ...

thanks,
Panin

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RadGridSolutionTelerik.aspx.cs" Inherits="RadGridSolutionTelerik" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">  
  
  
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>  
  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head>  
   <title></title>  
    <style type="text/css">  
      .StaticColumn  
      {      
          font-family: Arial,Verdana, Helvetica;  
        font-size: 14px;  
        font-weight: normal;     
          border: none;  
          position: relative;  
      }   
  
    </style>       
</head>  
<body>  
    <form runat="server" id="mainForm" method="post">          
      <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />  
        <!-- content start -->  
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
            <AjaxSettings>  
                <telerik:AjaxSetting AjaxControlID="RadGrid1">  
                    <UpdatedControls>  
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" />  
                        <telerik:AjaxUpdatedControl ControlID="RadGrid2" />  
                    </UpdatedControls>  
                </telerik:AjaxSetting>  
            </AjaxSettings>  
        </telerik:RadAjaxManager>  
        <table border="1" cellspacing="0" cellpadding="0" style="height:100%">   
        <tr>  
        <td style="vertical-align:top;height:100%">          
        <telerik:RadGrid ID="RadGrid1" OnPreRender="RadGrid1_PreRender" AutoGenerateColumns="False"  runat="server" DataSourceID="SqlDataSource1" OnColumnCreated="RadGrid1_ColumnCreated"  
            OnItemCreated="RadGrid1_ItemCreated" OnItemDataBound="RadGrid1_ItemDataBound" GridLines="Both">  
            <MasterTableView HierarchyDefaultExpanded="false" EnableNoRecordsTemplate="false" HierarchyLoadMode="ServerBind" AllowSorting="true" Width="800px"  
                DataKeyNames="EmployeeID">  
                <ItemStyle Wrap="false" Width="200px" Height="17px" BorderStyle="Groove" BorderWidth="1"/>  
                <AlternatingItemStyle Wrap="false" Width="200px" Height="17px" BorderStyle="Groove" BorderWidth="1"/>  
                <HeaderStyle Wrap="false" Width="1500px"/>  
                  
                <SelfHierarchySettings ParentKeyName="ReportsTo" KeyName="EmployeeID"/> 
                <GroupHeaderItemStyle BorderColor="red" BorderWidth="0"/> 
                <ExpandCollapseColumn ItemStyle-BackColor="red"></ExpandCollapseColumn> 
                <GroupHeaderItemStyle BackColor="green" /> 
                <RowIndicatorColumn HeaderStyle-BackColor="Blue"></RowIndicatorColumn> 
                <Columns>  
                    <telerik:GridBoundColumn SortExpression="EmployeeID" HeaderText="EmployeeID" HeaderButtonType="TextButton"  
                        DataField="EmployeeID" UniqueName="EmployeeID" ItemStyle-Wrap="false" ItemStyle-Width="200px" ItemStyle-Height="17px" ItemStyle-BorderWidth="1" ItemStyle-BorderStyle="Groove">  
                    </telerik:GridBoundColumn>  
                    <telerik:GridBoundColumn SortExpression="LastName" HeaderText="LastName" HeaderButtonType="TextButton"  
                        DataField="LastName" UniqueName="LastName" ItemStyle-Wrap="false" ItemStyle-Width="200px" ItemStyle-Height="17px" ItemStyle-BorderWidth="1" ItemStyle-BorderStyle="Groove">  
                    </telerik:GridBoundColumn>  
                    <telerik:GridBoundColumn SortExpression="FirstName" HeaderText="FirstName" HeaderButtonType="TextButton"  
                        DataField="FirstName" UniqueName="FirstName" ItemStyle-Wrap="false" ItemStyle-Width="200px" ItemStyle-Height="17px" ItemStyle-BorderWidth="1" ItemStyle-BorderStyle="Groove">  
                    </telerik:GridBoundColumn>  
                    <telerik:GridBoundColumn SortExpression="Title" HeaderText="Title" HeaderButtonType="TextButton"  
                        DataField="Title" UniqueName="Title" ItemStyle-Wrap="false" ItemStyle-Width="200px" ItemStyle-Height="17px" ItemStyle-BorderWidth="1" ItemStyle-BorderStyle="Groove">  
                    </telerik:GridBoundColumn>  
                    <telerik:GridBoundColumn SortExpression="ReportsTo" HeaderText="ReportsTo" HeaderButtonType="TextButton"  
                        DataField="ReportsTo" UniqueName="ReportsTo" ItemStyle-Wrap="false" ItemStyle-Width="200px" ItemStyle-Height="17px" ItemStyle-BorderWidth="1" ItemStyle-BorderStyle="Groove">  
                    </telerik:GridBoundColumn>   
                </Columns>  
            </MasterTableView>  
              
            <ClientSettings AllowExpandCollapse="true">              
            </ClientSettings>  
        </telerik:RadGrid>  
        </td>  
        <td class="StaticColumn" style="vertical-align:top;height:100%;">   
        <telerik:RadGrid ID="RadGrid2" ShowStatusBar="true"  
            runat="server" AutoGenerateColumns="False" PageSize="10" AllowSorting="True" AllowMultiRowSelection="False" Width="800px"  
            AllowPaging="false" GridLines="Both">  
            <PagerStyle Mode="NumericPages"></PagerStyle>  
            <MasterTableView ItemStyle-Wrap="false" Height="20px" HierarchyLoadMode="ServerBind" CanRetrieveAllData="true">  
                <ItemStyle Wrap="false" Width="200px" Height="17px" BorderWidth="1" BorderStyle="Groove" />  
                <AlternatingItemStyle Wrap="false" Width="200px" Height="17px" BorderWidth="1" BorderStyle="Groove"/>                                
                <Columns>  
                    <telerik:GridBoundColumn SortExpression="EmployeeID" HeaderText="EmployeeID" HeaderButtonType="TextButton"  
                        DataField="EmployeeID" UniqueName="EmployeeID" ItemStyle-Wrap="false" ItemStyle-Width="200px" ItemStyle-Height="17px" ItemStyle-BorderWidth="1" ItemStyle-BorderStyle="Groove">  
                    </telerik:GridBoundColumn>  
                    <telerik:GridBoundColumn SortExpression="LastName" HeaderText="LastName" HeaderButtonType="TextButton"  
                        DataField="LastName" UniqueName="LastName" ItemStyle-Wrap="false" ItemStyle-Width="200px" ItemStyle-Height="17px" ItemStyle-BorderWidth="1" ItemStyle-BorderStyle="Groove">  
                    </telerik:GridBoundColumn>  
                    <telerik:GridBoundColumn SortExpression="FirstName" HeaderText="FirstName" HeaderButtonType="TextButton"  
                        DataField="FirstName" UniqueName="FirstName" ItemStyle-Wrap="false" ItemStyle-Width="200px" ItemStyle-Height="17px" ItemStyle-BorderWidth="1" ItemStyle-BorderStyle="Groove">  
                    </telerik:GridBoundColumn>  
                    <telerik:GridBoundColumn SortExpression="Title" HeaderText="Title" HeaderButtonType="TextButton"  
                        DataField="Title" UniqueName="Title" ItemStyle-Wrap="false" ItemStyle-Width="200px" ItemStyle-Height="17px" ItemStyle-BorderWidth="1" ItemStyle-BorderStyle="Groove">  
                    </telerik:GridBoundColumn>  
                    <telerik:GridBoundColumn SortExpression="ReportsTo" HeaderText="ReportsTo" HeaderButtonType="TextButton"  
                        DataField="ReportsTo" UniqueName="ReportsTo" ItemStyle-Wrap="false" ItemStyle-Width="200px" ItemStyle-Height="17px" ItemStyle-BorderWidth="1" ItemStyle-BorderStyle="Groove">  
                    </telerik:GridBoundColumn>   
                    <telerik:GridBoundColumn SortExpression="EmployeeID" HeaderText="EmployeeID" HeaderButtonType="TextButton"  
                        DataField="EmployeeID" UniqueName="EmployeeID" ItemStyle-Wrap="false" ItemStyle-Width="200px" ItemStyle-Height="17px" ItemStyle-BorderWidth="1" ItemStyle-BorderStyle="Groove">  
                    </telerik:GridBoundColumn>  
                    <telerik:GridBoundColumn SortExpression="LastName" HeaderText="LastName" HeaderButtonType="TextButton"  
                        DataField="LastName" UniqueName="LastName" ItemStyle-Wrap="false" ItemStyle-Width="200px" ItemStyle-Height="17px" ItemStyle-BorderWidth="1" ItemStyle-BorderStyle="Groove">  
                    </telerik:GridBoundColumn>  
                    <telerik:GridBoundColumn SortExpression="FirstName" HeaderText="FirstName" HeaderButtonType="TextButton"  
                        DataField="FirstName" UniqueName="FirstName" ItemStyle-Wrap="false" ItemStyle-Width="200px" ItemStyle-Height="17px" ItemStyle-BorderWidth="1" ItemStyle-BorderStyle="Groove">  
                    </telerik:GridBoundColumn>  
                    <telerik:GridBoundColumn SortExpression="Title" HeaderText="Title" HeaderButtonType="TextButton"  
                        DataField="Title" UniqueName="Title" ItemStyle-Wrap="false" ItemStyle-Width="200px" ItemStyle-Height="17px" ItemStyle-BorderWidth="1" ItemStyle-BorderStyle="Groove">  
                    </telerik:GridBoundColumn>  
                    <telerik:GridBoundColumn SortExpression="ReportsTo" HeaderText="ReportsTo" HeaderButtonType="TextButton"  
                        DataField="ReportsTo" UniqueName="ReportsTo" ItemStyle-Wrap="false" ItemStyle-Width="200px" ItemStyle-Height="17px" ItemStyle-BorderWidth="1" ItemStyle-BorderStyle="Groove">  
                    </telerik:GridBoundColumn>       
                    <telerik:GridBoundColumn SortExpression="EmployeeID" HeaderText="EmployeeID" HeaderButtonType="TextButton"  
                        DataField="EmployeeID" UniqueName="EmployeeID" ItemStyle-Wrap="false" ItemStyle-Width="200px" ItemStyle-Height="17px" ItemStyle-BorderWidth="1" ItemStyle-BorderStyle="Groove">  
                    </telerik:GridBoundColumn>  
                    <telerik:GridBoundColumn SortExpression="LastName" HeaderText="LastName" HeaderButtonType="TextButton"  
                        DataField="LastName" UniqueName="LastName" ItemStyle-Wrap="false" ItemStyle-Width="200px" ItemStyle-Height="17px" ItemStyle-BorderWidth="1" ItemStyle-BorderStyle="Groove">  
                    </telerik:GridBoundColumn>  
                    <telerik:GridBoundColumn SortExpression="FirstName" HeaderText="FirstName" HeaderButtonType="TextButton"  
                        DataField="FirstName" UniqueName="FirstName" ItemStyle-Wrap="false" ItemStyle-Width="200px" ItemStyle-Height="17px" ItemStyle-BorderWidth="1" ItemStyle-BorderStyle="Groove">  
                    </telerik:GridBoundColumn>  
                    <telerik:GridBoundColumn SortExpression="Title" HeaderText="Title" HeaderButtonType="TextButton"  
                        DataField="Title" UniqueName="Title" ItemStyle-Wrap="false" ItemStyle-Width="200px" ItemStyle-Height="17px" ItemStyle-BorderWidth="1" ItemStyle-BorderStyle="Groove">  
                    </telerik:GridBoundColumn>  
                    <telerik:GridBoundColumn SortExpression="ReportsTo" HeaderText="ReportsTo" HeaderButtonType="TextButton"  
                        DataField="ReportsTo" UniqueName="ReportsTo" ItemStyle-Wrap="false" ItemStyle-Width="200px" ItemStyle-Height="17px" ItemStyle-BorderWidth="1" ItemStyle-BorderStyle="Groove">  
                    </telerik:GridBoundColumn>   
                    <telerik:GridBoundColumn SortExpression="EmployeeID" HeaderText="EmployeeID" HeaderButtonType="TextButton"  
                        DataField="EmployeeID" UniqueName="EmployeeID" ItemStyle-Wrap="false" ItemStyle-Width="200px" ItemStyle-Height="17px" ItemStyle-BorderWidth="1" ItemStyle-BorderStyle="Groove">  
                    </telerik:GridBoundColumn>  
                    <telerik:GridBoundColumn SortExpression="LastName" HeaderText="LastName" HeaderButtonType="TextButton"  
                        DataField="LastName" UniqueName="LastName" ItemStyle-Wrap="false" ItemStyle-Width="200px" ItemStyle-Height="17px" ItemStyle-BorderWidth="1" ItemStyle-BorderStyle="Groove">  
                    </telerik:GridBoundColumn>  
                    <telerik:GridBoundColumn SortExpression="FirstName" HeaderText="FirstName" HeaderButtonType="TextButton"  
                        DataField="FirstName" UniqueName="FirstName" ItemStyle-Wrap="false" ItemStyle-Width="200px" ItemStyle-Height="17px" ItemStyle-BorderWidth="1" ItemStyle-BorderStyle="Groove">  
                    </telerik:GridBoundColumn>  
                    <telerik:GridBoundColumn SortExpression="Title" HeaderText="Title" HeaderButtonType="TextButton"  
                        DataField="Title" UniqueName="Title" ItemStyle-Wrap="false" ItemStyle-Width="200px" ItemStyle-Height="17px" ItemStyle-BorderWidth="1" ItemStyle-BorderStyle="Groove">  
                    </telerik:GridBoundColumn>  
                    <telerik:GridBoundColumn SortExpression="ReportsTo" HeaderText="ReportsTo" HeaderButtonType="TextButton"  
                        DataField="ReportsTo" UniqueName="ReportsTo" ItemStyle-Wrap="false" ItemStyle-Width="200px" ItemStyle-Height="17px" ItemStyle-BorderWidth="1" ItemStyle-BorderStyle="Groove">  
                    </telerik:GridBoundColumn>                                                          
                </Columns>  
            </MasterTableView>  
            <clientsettings allowexpandcollapse="false" >                  
                    <Scrolling AllowScroll="true" UseStaticHeaders="True"></Scrolling>  
            </clientsettings>  
        </telerik:RadGrid>  
        </td>  
        </tr>  
        </table>          
        <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"  
            ProviderName="System.Data.SqlClient" SelectCommand="SELECT EmployeeID, LastName, FirstName, Title, ReportsTo FROM Employees"  
            runat="server"></asp:SqlDataSource>  
        <!-- content end -->  
    </form>  
</body>  
</html>  
 
 
 
 
 
 
 
 
 
 
 
 
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using Telerik.Web.UI; 
using System.Reflection; 
using System.Data; 
using System.Data.SqlClient;  
 
public partial class RadGridSolutionTelerik : System.Web.UI.Page 
{ 
 
    public void Page_Load(object sender, EventArgs e) 
    { 
        bindGrid2(); 
        if (Assembly.GetAssembly(typeof(ScriptManager)).FullName.IndexOf("3.5") != -1) 
        { 
            RadGrid1.MasterTableView.FilterExpression = @"it[""ReportsTo""] = Convert.DBNull"; 
        } 
        else 
        { 
            RadGrid1.MasterTableView.FilterExpression = "ReportsTo IS NULL"; 
        } 
    } 
 
    public void Page_PreRenderComplete(object sender, EventArgs e) 
    { 
        HideExpandColumnRecursive(RadGrid1.MasterTableView); 
 
        string ActualNodes = string.Empty; 
 
        foreach (GridDataItem dataItem in RadGrid1.Items) 
        { 
            if (dataItem.Visible) 
            { 
                ActualNodes += dataItem["EmployeeID"].Text + ","; 
            } 
        } 
 
 
        if (ActualNodes.Length > 0) 
            ActualNodesActualNodes = ActualNodes.Substring(0, ActualNodes.Length - 1); 
 
        RadGrid2.Controls.Clear(); 
        RadGrid2.DataSource = getDetails(ActualNodes); 
        RadGrid2.DataBind(); 
 
 
    } 
 
    public void HideExpandColumnRecursive(GridTableView tableView) 
    { 
        GridItem[] nestedViewItems = tableView.GetItems(GridItemType.NestedView); 
        foreach (GridNestedViewItem nestedViewItem in nestedViewItems) 
        { 
            foreach (GridTableView nestedView in nestedViewItem.NestedTableViews) 
            { 
                nestedView.Style["border"] = "0"; 
 
                Button MyExpandCollapseButton = (Button)nestedView.ParentItem.FindControl("MyExpandCollapseButton"); 
                if (nestedView.Items.Count == 0) 
                { 
                    if (MyExpandCollapseButton != null) 
                    { 
                        MyExpandCollapseButton.Style["visibility"] = "hidden"; 
                    } 
                    nestedViewItem.Visible = false; 
                } 
                else 
                { 
                    if (MyExpandCollapseButton != null) 
                    { 
                        MyExpandCollapseButton.Style.Remove("visibility"); 
                    } 
                } 
 
                if (nestedView.HasDetailTables) 
                { 
                    HideExpandColumnRecursive(nestedView); 
                } 
            } 
        } 
    } 
 
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        CreateExpandCollapseButton(e.Item, "EmployeeID"); 
 
        if (e.Item is GridHeaderItem && e.Item.OwnerTableView != RadGrid1.MasterTableView) 
        { 
            e.Item.Style["display"] = "none"; 
        } 
 
        if (e.Item is GridNestedViewItem) 
        { 
            e.Item.Cells[0].Visible = false; 
        } 
    } 
 
    protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e) 
    { 
        if (e.Column is GridExpandColumn) 
        { 
            e.Column.Visible = false; 
        } 
        else if (e.Column is GridBoundColumn) 
        { 
            e.Column.HeaderStyle.Width = Unit.Pixel(100); 
        } 
    } 
 
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        CreateExpandCollapseButton(e.Item, "EmployeeID"); 
    } 
 
    public void CreateExpandCollapseButton(GridItem item, string columnUniqueName) 
    { 
        if (item is GridDataItem) 
        { 
            if (item.FindControl("MyExpandCollapseButton") == null) 
            { 
                Button button = new Button(); 
                button.Click += new EventHandler(button_Click); 
                button.CommandName = "ExpandCollapse"; 
                button.CssClass = (item.Expanded) ? "rgCollapse" : "rgExpand"; 
                button.ID = "MyExpandCollapseButton"; 
 
                if (item.OwnerTableView.HierarchyLoadMode == GridChildLoadMode.Client) 
                { 
                    string script = String.Format(@"$find(""{0}"")._toggleExpand(this, event); return false;", item.Parent.Parent.ClientID); 
 
                    button.OnClientClick = script; 
                } 
                /* 
                int level = item.ItemIndexHierarchical.Split(':').Length; 
                if (level > 1) 
                { 
                    button.Style["margin-left"] = level + 10 + "px"; 
                    button.Style["height"] = "15px"; 
                } 
                */ 
                 
                TableCell cell = ((GridDataItem)item)[columnUniqueName]; 
                cell.Controls.Add(button); 
                //LiteralControl liSpace = new LiteralControl("&nbsp;"); 
                //cell.Controls.Add(liSpace);                 
                cell.Controls.Add(new LiteralControl(((GridDataItem)item).GetDataKeyValue(columnUniqueName).ToString())); 
                cell.Style["height"] = "15px"; 
                 
            } 
        } 
    } 
 
    protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
 
        string ActualNodes = string.Empty; 
 
        foreach (GridDataItem dataItem in RadGrid1.Items) 
        { 
            if (dataItem.Visible) 
            { 
                ActualNodes += dataItem["EmployeeID"].Text + ","; 
            } 
        } 
 
 
        if (ActualNodes.Length > 0) 
            ActualNodesActualNodes = ActualNodes.Substring(0, ActualNodes.Length - 1); 
 
        RadGrid2.Controls.Clear(); 
        RadGrid2.DataSource = getDetails(ActualNodes); 
        RadGrid2.DataBind(); 
        //Response.Write("<script> alert(" + sTest + ");</script>");  
    } 
 
 
    void button_Click(object sender, EventArgs e) 
    { 
        ((Button)sender).CssClass = (((Button)sender).CssClass == "rgExpand") ? "rgCollapse" : "rgExpand"; 
    } 
 
 
    private void bindGrid2() 
    { 
 
        RadGrid2.Controls.Clear(); 
        string initialNodes = string.Empty; 
        for (int m = 0; m < RadGrid1.Items.Count; m++) 
        { 
            if (!RadGrid1.Items[m]["EmployeeID"].Text.ToLower().Equals("&nbsp;") && RadGrid1.Items[m].Visible) 
                initialNodes += RadGrid1.Items[m]["EmployeeID"].Text + ","; 
        } 
 
        if (initialNodes.Length > 0) 
        { 
            RadGrid2.DataSource = getEmployees(initialNodes.Substring(0, initialNodes.Length - 1)); 
        } 
        else 
            RadGrid2.DataSource = getEmployees(""); 
 
        RadGrid2.DataBind(); 
    } 
 
    private DataView getEmployees(string initialNodes) 
    { 
        DataSet ds = new DataSet(); 
 
        string sqlFinal = string.Empty; 
        if (!initialNodes.Equals(string.Empty)) 
        { 
            sqlFinal = "Where EmployeeID in (" + initialNodes + ")"; 
        } 
 
        using (SqlConnection conn = new SqlConnection()) 
        { 
            conn.ConnectionString = GetConnectionString(); 
            SqlCommand cmd = new SqlCommand("SELECT [EmployeeID], [LastName], [FirstName], [Title], [ReportsTo] FROM [Employees] " + sqlFinal, conn); 
            conn.Open(); 
 
            SqlDataAdapter sqlAdapter = new SqlDataAdapter(cmd); 
 
            sqlAdapter.Fill(ds); 
        } 
 
        DataView dv = new DataView(ds.Tables[0]); 
        return dv; 
    } 
 
    private DataTable getChildNodesByID(string ParentID) 
    { 
        DataSet ds = new DataSet(); 
        string sql = "SELECT [EmployeeID], [LastName], [FirstName], [Title], [ReportsTo] FROM [Employees] Where ReportsTo = " + ParentID; 
 
        using (SqlConnection conn = new SqlConnection()) 
        { 
            conn.ConnectionString = GetConnectionString(); 
            SqlCommand cmd = new SqlCommand(sql, conn); 
            conn.Open(); 
 
            SqlDataAdapter sqlAdapter = new SqlDataAdapter(cmd); 
            sqlAdapter.Fill(ds); 
        } 
 
        DataTable dt = new DataTable(); 
        if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) 
            return ds.Tables[0]; 
        else 
            return null; 
    } 
 
    private DataView getDetails(string ActualNodes) 
    { 
        DataSet ds = new DataSet(); 
 
 
        //string noeuds = ActualNodes.Substring(0, ActualNodes.Length - 1);  
 
        string[] tabNoeuds = ActualNodes.Split(','); 
        string swhen = " CASE "; 
 
        for (int i = 0; i < tabNoeuds.Length; i++) 
        { 
            swhen += " WHEN EmployeeID = " + tabNoeuds[i] + " THEN " + (i + 1) + " "; 
        } 
        swhen += " END "; 
 
        string sql = "SELECT [EmployeeID], [LastName], [FirstName], [Title], [ReportsTo] FROM [Employees] Where EmployeeID in (" + ActualNodes + ")"; 
        sql += " ORDER BY " + swhen; 
        using (SqlConnection conn = new SqlConnection()) 
        { 
            conn.ConnectionString = GetConnectionString(); 
            SqlCommand cmd = new SqlCommand(sql, conn); 
            conn.Open(); 
 
            SqlDataAdapter sqlAdapter = new SqlDataAdapter(cmd); 
            sqlAdapter.Fill(ds); 
        } 
 
        DataView dv = new DataView(ds.Tables[0]); 
        return dv; 
    } 
 
 
 
    static private string GetConnectionString() 
    { 
        return "server=STATION00374;database=Northwind;Integrated Security=SSPI;"; 
    } 
} 

RadTony
Top achievements
Rank 1
 answered on 03 Feb 2010
1 answer
127 views
I have a grid using simple binding method with a collection of business objects.  Properties are declared in markup using the DataField attribute.  Some properties are in nested objects and are qualified using dot notation.  Properties are largely strings with a few dates and numeric. 

Deployed app on 64-bit server with an Intel Xeon E7220 with 8 GB RAM running on Windows Server 2003 R2.  Using 64-bit .NET 2.0 framework.  When deployed, the binding of 100 rows with 40 columns takes about 700 ms.  This seems high to me.

I assume the object binding is achieved with reflection.  Are there optimizations in place?  What's the best performing method of binding data to a grid?
Nikolay Rusev
Telerik team
 answered on 03 Feb 2010
2 answers
322 views
How do you turn off the cursor from appearing inside the combo box?

The behavior suggests that I can edit the contents of the box, but I am unable to.
Princy
Top achievements
Rank 2
 answered on 03 Feb 2010
1 answer
64 views
Hi,
 In my scheduler I am using resources grouping to show multiple users. How can I get the resource in OnClientTimeSlotClick event?
Peter
Telerik team
 answered on 03 Feb 2010
4 answers
628 views
Hi,

I am trying to populate a radgrid from the data I stored in a backend database, which has a text field. The text field has contents added through a multi-line text box in more than one paragraph. However, when the data is displayed in the grid, the paragraphs are all merged together and the data is displayed as a single paragraph. Is there anything I can do to maintain this while displaying the data in radgrid.

many thanks,

Anu
Dimo
Telerik team
 answered on 03 Feb 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?