Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
174 views
Having just purchased the controls I'm putting together a RadGrid that contains one of each datatype to enable me to learn how the control works and am having an issue with the Rating control.

I have a SQL procedure which returns a dataset which is bound to a datatable in the code.  This contains HotelName, Obsolete and Rating columns at present.

I've attached the code below (except the class file which handles the data call).  When I press the button I get the hotel names and the checkbox is set correctly, however the rating control does not display.  However if I press the button again, or press the HotelName header to sort the column the rating then appears...anyone know what I'm not doing...?

Cheers
Cliff


Default.aspx

<%

 

@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

 

<%

 

@ 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">

 

 

 

<div>

 

 

 

<telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server">

 

 

 

</telerik:RadStyleSheetManager>

 

 

 

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

 

 

 

</telerik:RadScriptManager>

 

 

 

<telerik:RadSkinManager ID="RadSkinManager1" runat="server" Skin="Windows7">

 

 

 

</telerik:RadSkinManager>

 

 

 

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

 

 

 

<AjaxSettings>

 

 

 

<telerik:AjaxSetting AjaxControlID="Button1">

 

 

 

<UpdatedControls>

 

 

 

<telerik:AjaxUpdatedControl ControlID="RadTextBox1" />

 

 

 

<telerik:AjaxUpdatedControl ControlID="RadGrid1" />

 

 

 

</UpdatedControls>

 

 

 

</telerik:AjaxSetting>

 

 

 

<telerik:AjaxSetting AjaxControlID="RadGrid1">

 

 

 

<UpdatedControls>

 

 

 

<telerik:AjaxUpdatedControl ControlID="RadGrid1" />

 

 

 

</UpdatedControls>

 

 

 

</telerik:AjaxSetting>

 

 

 

</AjaxSettings>

 

 

 

</telerik:RadAjaxManager>

 

 

 

<telerik:RadTextBox ID="RadTextBox1" runat="server">

 

 

 

</telerik:RadTextBox>

 

 

 

<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />

 

 

 

<telerik:RadGrid

 

 

 

ID="RadGrid1" runat="server" AutoGenerateColumns="False" GridLines="None"

 

 

 

onneeddatasource="RadGrid1_NeedDataSource" Visible="False"

 

 

 

onitemdatabound="RadGrid1_ItemDataBound" AllowSorting="True">

 

 

 

<MasterTableView>

 

 

 

<RowIndicatorColumn>

 

 

 

<HeaderStyle Width="20px"></HeaderStyle>

 

 

 

</RowIndicatorColumn>

 

 

 

<ExpandCollapseColumn>

 

 

 

<HeaderStyle Width="20px"></HeaderStyle>

 

 

 

</ExpandCollapseColumn>

 

 

 

<Columns>

 

 

 

<telerik:GridTemplateColumn Visible="False">

 

 

 

<ItemTemplate>

 

 

 

<asp:Label ID="lblHiddenHotelID" runat="server" Text='<%# Eval("pkHotelID") %>' style="display:none"></asp:Label>

 

 

 

<asp:Label ID="lblHiddenObsolete" runat="server" Text='<%# Eval("Obsolete") %>' style="display:none"></asp:Label>

 

 

 

</ItemTemplate>

 

 

 

</telerik:GridTemplateColumn>

 

 

 

 

<telerik:GridTemplateColumn HeaderText="Hotel" SortExpression="HotelName">

 

 

 

<ItemTemplate>

 

 

 

<asp:Label ID="lblHotelName" runat="server" Text='<%# Eval("HotelName") %>'></asp:Label>

 

 

 

</ItemTemplate>

 

 

 

</telerik:GridTemplateColumn>

 

 

 

 

<telerik:GridTemplateColumn HeaderText="Obsolete">

 

 

 

<ItemTemplate>

 

 

 

<asp:CheckBox ID="chkObsolete" runat="server"></asp:CheckBox>

 

 

 

</ItemTemplate>

 

 

 

</telerik:GridTemplateColumn>

 

 

 

 

<telerik:GridTemplateColumn HeaderText="Rating">

 

 

 

<ItemTemplate>

 

 

 

<telerik:RadRating ID="RadRatingHotel" runat="server" ItemCount="5" Precision="Item"

 

 

 

Value='<%# Convert.ToDouble(Eval("Rating")) %>'>

 

 

 

</telerik:RadRating>

 

 

 

</ItemTemplate>

 

 

 

</telerik:GridTemplateColumn>

 

 

 

 

</Columns>

 

 

 

</MasterTableView>

 

 

 

</telerik:RadGrid>

 

 

 

</div>

 

 

 

</form>

 

</

 

 

body>

 

</

 

 

html>

 






Default.aspx.cs

using

 

 

System;

 

using

 

 

System.Collections.Generic;
using System.Web;

 

using

 

 

System.Web.UI;

 

using

 

 

System.Web.UI.WebControls;

 

using

 

 

System.Data;

 

using

 

 

System.Data.SqlClient;

 

using

 

 

Telerik.Web.UI;

 

public

 

 

partial class _Default : System.Web.UI.Page

 

{

#region

 

 

Properties

 

 

 

string connString = System.Configuration.ConfigurationManager.ConnectionStrings["EventMgmtCS"].ToString();

 

#endregion

#region

 

 

DataTables

 

 

 

DataTable HotelSearchResults

 

{

 

 

get

 

{

 

 

SqlParameterCollection sqlParams = new SqlCommand().Parameters;

 

sqlParams.Add(

 

Napp_SQLServer.BuildSQLCommandParamater("@search_type", "Hotel Name", System.Data.SqlDbType.VarChar, System.Data.ParameterDirection.Input));

 

sqlParams.Add(

 

Napp_SQLServer.BuildSQLCommandParamater("@hotel_name", RadTextBox1.Text, System.Data.SqlDbType.VarChar, System.Data.ParameterDirection.Input));

 

 

 

DataTable dt = Napp_SQLServer.BuildDataTableWithParameters(connString, "proc_hotel_search", sqlParams);

 

 

 

return dt;

 

}

}

#endregion

 

#region

 

 

Events

 

 

 

protected void Button1_Click(object sender, EventArgs e)

 

{

RadGrid1.Visible =

 

true;

 

RadGrid1.Rebind();

}

 

 

 

protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)

 

{

RadGrid1.DataSource = HotelSearchResults;

}

 

 

 

protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)

 

{

 

 

if (e.Item.ItemType == Telerik.Web.UI.GridItemType.Item | e.Item.ItemType == Telerik.Web.UI.GridItemType.AlternatingItem | e.Item.ItemType == Telerik.Web.UI.GridItemType.EditItem | e.Item.ItemType == Telerik.Web.UI.GridItemType.SelectedItem)

 

{

 

 

//declare all the items in the grid

 

 

 

 

Label lblHiddenObsolete = (Label)e.Item.FindControl("lblHiddenObsolete");

 

 

 

CheckBox chkObsolete = (CheckBox)e.Item.FindControl("chkObsolete");

 

 

 

if (lblHiddenObsolete.Text == "True")

 

{

chkObsolete.Checked =

 

true;

 

}

 

 

else

 

{

chkObsolete.Checked =

 

false;

 

}

}

}

#endregion

}



Mira
Telerik team
 answered on 14 May 2010
5 answers
155 views

I'm using a radtabstrip and radmultipage to move a user through a complex form and get payment at end (using sagepay/protx). I tried using Response.Redirect/RadScriptManager.Redirect/RadAjaxPanel.redirect - also IFRAME and RadWindows but none of these approaches worked because of potential security issues.

The fix was wrapping this line of code within the server side event click - and then double-clicking on the button to execute javascript.

 

btnMakePayment.Attributes.Add(

 

"onClick", string.Format("window.open('{0}', '{1}');return false;", response.NextURL, "winSagepay"));

radwin.open would fail (see a response from teh telerik team), the radwindow uses IFRAME (see another response from telerik team) - and the rest don't work. They did work under some circumstances (in a dev environment) but not when I put the code on a test box.

 

 

This is a HACK - I would love to hear how others have approached this problem.

Iana Tsolova
Telerik team
 answered on 14 May 2010
1 answer
90 views
I am creating radtree node and radgrid dynamically

when I am creating the radgrid dynamically and attaching to the treenode i am getting the script error.

---------------------------
Microsoft Internet Explorer
---------------------------
Script control '' is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors().Parameter name: scriptControl
---------------------------
OK   
---------------------------

below is the code for the controls i build, plz help me this is strange error which i never get.



using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using Telerik.Web.UI;
using System.Web.UI.HtmlControls;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
public partial class NewBusiness : System.Web.UI.Page
{
    private void AddChildNodes(RadTreeNode tNode1)
    {
        if (tNode1.Text == "POLICY")
        {
            BindPolicy(tNode1);
        }
        else if (tNode1.Text == "ENTITIES")
        {
            NodeTxt = BindGrids(tNode1, tNode1.Text, "~/XMLs/EntitiesInfo.xml");
            tNode1.Text = "ENTITIES" + " (" + NodeTxt + ")";

            if (!object.Equals(Session["Node"], null))
            {
                if (Session["Node"].ToString().Trim().Length > 0 && Session["Node"].ToString().Equals(tNode1.Text))
                {
                    tNode1.Expanded = true;
                }
            }
        }
        else if (tNode1.Text == "COVERAGE")
        {
            BindCoverage(tNode1);
        }
        else if (tNode1.Text == "VEHICLES")
        {
            NodeTxt = BindGrids(tNode1, tNode1.Text, "~/XMLs/Vehicle.xml");
            tNode1.Text = "VEHICLES" + " (" + NodeTxt + ")";
            if (!object.Equals(Session["Node"], null))
            {
                if (Session["Node"].ToString().Trim().Length > 0 && Session["Node"].ToString().Equals(tNode1.Text))
                {
                    tNode1.Expanded = true;
                }
            }

        }
        else if (tNode1.Text == "DRIVERS")
        {
            NodeTxt = BindGrids(tNode1, tNode1.Text, "~/XMLs/DriversInfo.xml");
            tNode1.Text = "DRIVERS" + " (" + NodeTxt + ")";
            if (!object.Equals(Session["Node"], null))
            {
                if (Session["Node"].ToString().Trim().Length > 0 && Session["Node"].ToString().Equals(tNode1.Text))
                {
                    tNode1.Expanded = true;
                }
            }

        }
        else if (tNode1.Text == "HISTORY")
        {
            NodeTxt = BindGrids(tNode1, tNode1.Text, "~/XMLs/CarrierInfo.xml");
            tNode1.Text = "HISTORY" + " (" + NodeTxt + ")";
        }

        else if (tNode1.Text == "RATE")
        {
            BindRate(tNode1);
        }
    }

    private string BindGrids(RadTreeNode tNode1, string NodeText, string xmlpath)
    {
        string strgrid = string.Empty;
        rdGrid = new RadGrid();

        RadScriptManager1.RegisterScriptControl(rdGrid);

        ds = new DataSet();
        ds.ReadXml(Server.MapPath(xmlpath));
        Session["ds"] = ds;

        rdGrid.AllowPaging = true;
        rdGrid.GridLines = GridLines.None;
        rdGrid.SelectedItemStyle.CssClass = "MySelectedClass";
        rdGrid.CommandItemStyle.Wrap = true;
        rdGrid.AlternatingItemStyle.BackColor = Color.White;
        rdGrid.PagerStyle.AlwaysVisible = true;
        rdGrid.AutoGenerateColumns = false;
        rdGrid.ItemStyle.Width = 30;
        rdGrid.Width = Unit.Pixel(240);
        rdGrid.DataSource = ds;

        GridBoundColumn sno = new GridBoundColumn();
        sno.DataField = "SNo";
        sno.HeaderText = "#";
        sno.HeaderStyle.Width = Unit.Pixel(10);
        sno.ItemStyle.Width = Unit.Pixel(10);
        sno.HeaderStyle.CssClass = "grdHdr";
        sno.FooterStyle.CssClass = "grdPager";
        sno.ItemStyle.CssClass = "grdItem";
        rdGrid.MasterTableView.Columns.Add(sno);

        GridBoundColumn Name = new GridBoundColumn();
        if (NodeText == "VEHICLES" || NodeText == "RVEHICLES")
        {
            Name.DataField = "VIN";
            Name.HeaderText = "VIN";
        }
        else if (NodeText == "HISTORY")
        {
            Name.DataField = "CarrierName";
            Name.HeaderText = "CarrierName";
        }
        else if (NodeText == "Locations")
        {
            Name.DataField = "Location";
            Name.HeaderText = "Location";
        }
        else if (NodeText != "Vehicles")
        {
            Name.DataField = "Name";
            Name.HeaderText = "Name";
        }

        Name.HeaderStyle.Width = Unit.Pixel(130);
        Name.ItemStyle.Width = Unit.Pixel(130);
        Name.HeaderStyle.CssClass = "grdHdr";
        Name.FooterStyle.CssClass = "grdPager";
        Name.ItemStyle.CssClass = "grdItem";
        Name.ItemStyle.Wrap = false;
        rdGrid.MasterTableView.Columns.Add(Name);

        if (NodeText != "Locations" && NodeText != "RVEHICLES")
        {
            GridButtonColumn delete = new GridButtonColumn();
            delete.HeaderStyle.Width = Unit.Percentage(5);
            delete.HeaderText = "Delete";
            delete.ButtonType = Telerik.Web.UI.GridButtonColumnType.ImageButton;
            delete.ImageUrl = "../Images/deleteicon_disabled.gif";
            delete.ConfirmDialogType = GridConfirmDialogType.RadWindow;
            delete.ConfirmText = "Are you sure want to delete Applicant?";
            delete.HeaderStyle.CssClass = "grdHdrDel";
            delete.ItemStyle.CssClass = "grdItemDel";
            delete.FooterStyle.CssClass = "grdPager";
            rdGrid.MasterTableView.Columns.Add(delete);
        }
        rdGrid.MasterTableView.ClientDataKeyNames = new String[] { "SNo" };
        rdGrid.ClientSettings.Selecting.AllowRowSelect = true;
        rdGrid.ClientSettings.ClientEvents.OnRowSelected = "RowSelected";

        rdGrid.DataSource = ds.Tables[0];
        rdGrid.DataBind();

        // rdGrid.NeedDataSource += new GridNeedDataSourceEventHandler(rdGrid_NeedDataSource);
        RadTreeNode tNode = new RadTreeNode();
        tNode.Controls.Add(rdGrid);
        tNode1.Nodes.Add(tNode);

        return ds.Tables[0].Rows.Count.ToString();
    }

}



Shinu
Top achievements
Rank 2
 answered on 14 May 2010
1 answer
80 views

Hi,

 

I want show below like this. Based on the dates range  I want show the events with recurrence events. how to show the events in Radgrid control or any control to show like this.

 sample:

From :  5/2/2010      To : 5/15/2010      | show button |

Name Start Time End Time Subject Description  (  Page Header )
5/2/2010 ( sub heading )

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

5/2/2010                             10pm              11 pm               meeting with client          discussion abut requirements

5/2/2010                             11 pm               1 pm               visit doctor                      remainder

5/4/2010 ( sub heading )

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

5/4/2010                            8 pm                  9 pm                meeting with realtor       completion on the wall construct 

-

-

-

-

-

-

5/6/2010 ( sub heading )

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

-

-

-

-

-

 

 

 

Peter
Telerik team
 answered on 14 May 2010
4 answers
376 views

I wanted a RadNumericTextBox and a RadDateTimePicker to be loaded hidden, but later be made visible via javascript.  Perhaps the most elegant solution is to use AJAX, but in my case I want the hide and unhide to always happen instantly, so javascript is the best choice.  I found a work around for both, but it's ugly.  Perhaps I overlooked something.  Perhaps a future release can handle this issue better.  Here's my solution.

Initialization

Protected Overrides Sub CreateChildControls()  
...  
    RadDateTimePicker1.Style("display") = "none" 
...  
    RadNumericTextBox1.ClientEvents.OnLoad = "function(){$find(""" & RadNumericTextBox1.ClientID & """).set_visible(false);}"  
...  
End Sub 

Javascript display function
var display = function(control, visible) {  
    if (control.style) { //normal  
        control.style.display = visible ? "" : "none";  
    }  
    else {  
        if (control._numberFormat) { //numeric  
            control.set_visible(visible);  
        }  
        else { //datetime  
            $get(control.get_id() + "_wrapper").style.display = visible ? "inline-block" : "none";  
        }  
    }  

As odd as this approach is, it's the most straight forward one I could find.  Any better suggestions?
Wyatt
Top achievements
Rank 1
 answered on 14 May 2010
2 answers
179 views
Hello,

I was wondering if it's possible to set something up like this using the RadAjaxPanel or RadAjaxManager: http://www.pageflakes.com/

Since the RadAjaxPanel can refresh its content using a client-side ajaxRequest() method, I thought that wouldn't be much of a challenge.  I have a UI that's like the following, for testing purposes.

RadAjaxPanel
    Grid
RadAjaxPanel
    Grid
RadAjaxPanel
    Grid
RadAjaxPanel
    Grid

However, when there are multiple panels and multiple calls to ajaxRequest, even though each call is to a different panel, only the last one succeeds.  I changed the code sample to use the RadAjaxManager, but I am still getting the same issue...

Any ideas how to set this up?  The key is I don't want to render data initially, but in client side page load, I want all of this to happen so that the user isn't waiting for the long rendering time.

Thanks.
Iana Tsolova
Telerik team
 answered on 14 May 2010
1 answer
47 views
Hi Telerik Support,

I am trying to Bind RadGrid TextBox to a RadToolTipManager's targetcontrols collection as per the demo in the Grid's ItemDataBound handler.  I also want the Grid to default to edit mode as per the other demo in the Grid's pre-render event.  The problem that I am having is that the DataBind/Rebind which is necessary to put the Grid into edit mode is calling the Databound event - its a bit chicken and egg - is there anyway around this?  also could you give me a pointer to activating the tooltip on entering and leaving the textbox using the tab-key ie onkeydown.

Kind regards,

Ashley
Iana Tsolova
Telerik team
 answered on 14 May 2010
3 answers
154 views

The problem is that we can’t set the Page Size greater than the Items Count.

We want to be able to set the page size 10 even if there is 4 items in the source list.

 

Steps to reproduce: bind to the grid the source with 4 items, try to enter 10 to the Page Size texbox, press Change button.

Actual result: the value of the textbox is turned back to previous value.

Expected result: the page size is changed to 10

 

The aspx code :

 

<telerik:RadGrid ID="dgdTransList" runat="server" AutoGenerateColumns="True"

    GridLines="None" EnableAJAX="true" PageSize="5" ShowFooter="true"

    AllowPaging="true" 

  

    <PagerStyle

        Visible="true"

        Mode="NextPrevNumericAndAdvanced"

        AlwaysVisible="true"

       

        />

       

</telerik:RadGrid>

 

The cs code :

 

        void dgdTransList_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)

        {

 

            ArrayList list = new ArrayList(new object[] { "one", "two", "three", "four" });

 

            dgdTransList.DataSource = list;

        }

 

Can you please tell us is there any workaround?

Pavlina
Telerik team
 answered on 14 May 2010
2 answers
114 views
I have a panel bar which is divided into sections.  Within each subsection there are RadPanelItems that are links to other pages.  One of the things I do is to put a number such as (59) next to the item text to indicate how many items will be listed when the user clicks on the link. 

With the aid of RadAjaxManager I am updating the links via an Ajax call when the section is expanded. i.e.I am hooking into the ItemOnclick event and updating the links in the expanded section.  However, an Ajax postback occurs when I contract the section as well - it is this postback that I want to avoid. 

Any suggestions on how to do this?

Thanks.
Sphengle
Top achievements
Rank 1
 answered on 14 May 2010
2 answers
135 views
Hi,
i have a gridattachmentcolumn, when i set the imageurl at runtime i can't see the image
post some code:

     <telerik:GridAttachmentColumn UniqueName ="colTPdf" FileNameTextField="ORT.OTCLIE" AttachmentKeyFields="ORT.OTNUOR" Text="Scarica ordine" ImageUrl="~/images/icoGear.png" > 
            </telerik:GridAttachmentColumn> 

thank you
Matteo Beretta
Top achievements
Rank 1
 answered on 14 May 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?