Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
1.4K+ views
Hi,

I have a radgrid, which has one of the column say Status. The datatype of value for this column Status is bool.
I am setting text of each cell of Status column to depending on some conditions, in the rdgrid_ItemDataBound event.
string str = "A", "AAB", "ABC", "ABCD"
So, depending on some specific conditions met, str can be any of the above values.

If e.item.cell[9].Text == "True"
    e.item.cell[9].Text = "A";

If e.item.cell[9].Text == "False"
e.item.cell[9].Text = "AAB";

If e.item.cell[9].Text == "True" && e.item.cell[7].Text = "False"
e.item.cell[9].Text = "ABCD";

I want to apply string filter on this column. Say I enter "ABCD" in the filter for this column of grid from UI, it should give me result for value "ABCD" only.

Thanks


access
Top achievements
Rank 1
 answered on 26 Jul 2014
1 answer
89 views
function rowSelected(sender, args) {
 
      UserID = getDataItemKeyValue(sender, args.get_gridDataItem());
 
      currentRowIndex = args.get_gridDataItem().get_element().rowIndex;
 
     $find("<%= RadTabStrip1.ClientID %>").set_selectedIndex(0);
 
     MyWebService.GetUserByUserID(UserID, setValues)
}
I tried following link:
http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/insert-update-delete-client/defaultcs.aspx

and made a project
I change some method name and column name about database.

I made ServiceReference :
<telerik:RadScriptManager ID="ScriptManager1" runat="server">
      <Services>
          <asp:ServiceReference Path="MyWebService.asmx" />
      </Services>
</telerik:RadScriptManager>

but I will got error in JavaScript,MyWebService is undefined

I also tried
RadScriptManager.GetCurrent(this).Services.Add(new ServiceReference(ResolveUrl("MyWebService.asmx")));

but also the same.

Could somebody help me?
I use Windows 8.1,Visual Studio 2012 Professional,SQL Server 2014.
And browser is IE 11.

Hsuani
Top achievements
Rank 1
 answered on 26 Jul 2014
2 answers
204 views
Hi

First post on Telerik Forum, hope will receive satisfactory and quick answer. Excuse me for my English and formatting....
I have created a User Control.ascx, inside it, I have RadFileExplorer.

<telerik:RadFileExplorer ID="RadFileExplorer1" Runat="server" EnableAsyncUpload="True" Width="100%">
<Configuration SearchPatterns="*.*" EnableAsyncUpload="True" UploadPaths="~/FolderSource" ViewPaths="~/FolderSource" ></Configuration>
</telerik:RadFileExplorer>

I am populating RadWindow with above UserControl.ascx dynamically. 

<telerik:RadWindow ID="DocumentRadWindow" runat="server" Height="600px" Width="1000px" Modal="true">
        <ContentTemplate>
            <asp:PlaceHolder ID="DocumentPlaceHolder" runat="server" />
        </ContentTemplate>
</telerik:RadWindow

//CodeBehind
   
protected void RadTabStripDocument_TabClick(object sender, Telerik.Web.UI.RadTabStripEventArgs e)
    {
        string TabText = e.Tab.Text;

        if (TabText == "Upload Document")
        {
            UserControl DocumentSort = (UserControl)LoadControl("~/DesktopModules/Document/DocumentUpload/DocumentUpload.ascx");
            
            DocumentPlaceHolder.Controls.Add(DocumentSort);
            DocumentRadWindow.VisibleOnPageLoad = true;
        }
    }

 During Upload,Delete and even clicking on Refresh button, it throws an pupup error "Callback has failed". And nothing happen, except loading image.














Muneer Raza
Top achievements
Rank 1
 answered on 25 Jul 2014
2 answers
134 views
Hi

I use the next code  for change the background the radeditor but the  cursor appears in the center. i use internet explore. I have one question it is a error or exists a bug

Thanks.








Gustavo
Top achievements
Rank 1
 answered on 25 Jul 2014
2 answers
248 views
Hi,

I am using a RadNumericTextbox in a DetailsView control to display a decimal value coming from a SQL query.
The original value from the database is "23,3000" with decimal type.
When displayed in a conventional ASP Textbox, the value is correctly displayed, even when I use:
Text='<%# Convert.ToDecimal(Eval("PriceInclTax")) %>'

When I pass exactly the same value to the RadNumericTextbox, I always get the value "233000" as an integer.

I am using the following code in aspx:

 

<telerik:RadNumericTextBox ID="PriceInclTaxTextBox" runat="server" Value='<%# Convert.ToDecimal(Eval("PriceInclTax")) %>' NumberFormat-DecimalDigits="4"></telerik:RadNumericTextBox>



I tried to change the Culture, NumberFormat-DecimalDigits, NumberFormat-GroupSeparator, NumberFormat-DecimalSeparator and Datatype parameters but with no luck. Another aproach was to divide the result by 10000, but only dividing by 1000 is showing the "comma" in the original value as "233,0000". Dividing by 10000 has the same result as dividing by 1000.
Any help?
JAIME
Top achievements
Rank 1
 answered on 25 Jul 2014
10 answers
549 views

I am using the PivotGrid to connect to the cube. But unless I give permission to Everyone, I can’t connect to the cube using the domain account I have.

 

Here is how I set it up:

 

<OlapSettings ProviderType="Adomd">

    <AdomdConnectionSettings Cube="FCube"

                             DataBase="FirstCube"

                             ConnectionString="Data Source=XXX;Catalog=FirstCube;User Id=xxx\xxx;password=xxxx;">

     </AdomdConnectionSettings>                  

</OlapSettings>

 

Please let me know what I should do.

Maria Ilieva
Telerik team
 answered on 25 Jul 2014
1 answer
195 views
I am currently trying to follow the RadCalendar and RadTooltipManager demo for my project but an experiencing some strange behavior.

When I come to the page for the first time the day cells will not show their tooltips, however when I click a day which causes an AJAX postback I have setup with rad ajax manager, the tooltips will start showing normally.

I have also tried using a RadAjaxPanel with RadTooltipManager, RadCalendar, and RadListView all inside, as well as an asp UpdatePanel with UpdateMode conditional with the other controls inside it as well, when using these methods the tooltips will not appear at all even after postbacks.

I think it might have to do with adding the controls to the TargetControls collection?

Also, I am doing this as a module for DotNetNuke if that information helps at all.

Relevant ASCX Code:
<telerik:RadAjaxLoadingPanel ID="LoadingPanel" runat="server" Skin="Metro"></telerik:RadAjaxLoadingPanel>
<telerik:RadAjaxManager ID="AjaxManager" runat="server" EnablePageHeadUpdate="false" EnableAJAX="true">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="rcPassCalendar">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="rlvDayClassesInfo" LoadingPanelID="LoadingPanel" />
                <telerik:AjaxUpdatedControl ControlID="rcPassCalendar" LoadingPanelID="LoadingPanel" />
                <telerik:AjaxUpdatedControl ControlID="TooltipManager" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
 
<telerik:RadToolTipManager ID="TooltipManager" runat="server" OnAjaxUpdate="TooltipManager_AjaxUpdate" Position="MiddleRight" Width="300" Height="300" RelativeTo="Element"
    Animation="Fade" AnimationDuration="250" ShowDelay="0" Skin="Glow">
</telerik:RadToolTipManager>
 
<telerik:RadCalendar ID="rcPassCalendar" runat="server" AutoPostBack="True" ShowRowHeaders="False" ShowOtherMonthsDays="False" Width="100%"
    OnSelectionChanged="rcPassCalendar_SelectionChanged" OnDayRender="rcPassCalendar_DayRender" EnableMultiSelect="false" EnableMonthYearFastNavigation="true" CellVAlign="Top" DefaultCellPadding="0"
    ShowDayCellToolTips="false">
    <FooterTemplate>
        <asp:Panel ID="pnlCalendarInstruction" runat="server" CssClass="dnnFormMessage dnnFormWarning" style="margin-bottom:0px;">
            Please select a day in the calendar above to see the sessions occurring on that day below.
        </asp:Panel>
    </FooterTemplate>
    <CalendarDayTemplates>
        <telerik:DayTemplate ID="Class" runat="server">
            <Content>
                <asp:Panel ID="pnlDaySessions" runat="server" CssClass="classDay">
                     
                </asp:Panel>
            </Content>
        </telerik:DayTemplate>
    </CalendarDayTemplates>
</telerik:RadCalendar>

Relevant C# Codebehind:
protected void rcPassCalendar_DayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e)
        {
            DateTime calendarDate = e.Day.Date;
            var daySessionQuery = from session in MonthsSessions
                                  where session.StartDt.Date == calendarDate.Date
                                  select session;
 
            //Need to ad an ID to the calendar cells, they don't have one by default.
            string uniqueDayNumber = e.Day.Date.Day.ToString() + e.Day.Date.Month.ToString() + e.Day.Date.Year.ToString();
 
             
            e.Cell.Attributes.Add("id", "Calendar_" + uniqueDayNumber);
            TooltipManager.TargetControls.Add(e.Cell.Attributes["id"], e.Day.Date.Day.ToString(), true);
 
            if (daySessionQuery != null && daySessionQuery.Count() > 0)
            {
                //e.Cell.Controls.Add(BuildEventDayControls(daySessionQuery, e.Day.Date.Day.ToString()));
 
                if (calendarDate.Month == rcPassCalendar.FocusedDate.Month)
                {
                    rcPassCalendar.SpecialDays.Add(e.Day);
                }
                     
            }
        }
Danail Vasilev
Telerik team
 answered on 25 Jul 2014
5 answers
816 views
I have created a radgrid that displays labels in the first column and input controls in column 2. Column 2 can have either textbox or  DropDownList controls. What I can't figure out is how to get the values of the input controls when the form is submitted

I have tried the following but the XControl is always null. I would like to return the grid contents as XML if possible

foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
            {
                TextBox xControl = item["AttributeType"].FindControl("tb") as TextBox;
            }

Any help/ideas would greatly be appreciated!!!



ASPX Markup

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

<%@ 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" style="height: 503px;" >
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
      <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="SpaceType" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="SpaceType">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <div>
    
    </div>
    <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None"
        OnItemCreated="RadGrid1_ItemCreated" Width="350px" Height="200px"  
        
        style="z-index: 1; left: 137px; top: 111px; position: absolute; height: 46px; width: 366px"
        AutoGenerateColumns="False" BorderStyle="None" >
<MasterTableView>
    <ItemTemplate>
    <%--This is required for Dynamic Creation of ItemTemplate Controls--%>
    </ItemTemplate>
    <Columns>
        <telerik:GridBoundColumn DataField="AttributeName" UniqueName="AttributeName"
            HeaderText="Space Attribute">
            <HeaderStyle Width="100px" />
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="AttributeType" UniqueName="AttributeType"
            HeaderText="Value">
            <HeaderStyle Width="75px" />
        </telerik:GridBoundColumn>
     </Columns>
</MasterTableView>
    </telerik:RadGrid>
    
    <asp:Button ID="Button1" runat="server" Text="Button"
        style="z-index: 1; left: 516px; top: 254px; position: absolute"
        onclick="Button1_Click" />
    
   
    <telerik:RadComboBox ID="SpaceType" Runat="server"
        style="z-index: 5; left: 273px; top: 63px; position: absolute; height: 22px; width: 160px; right: 486px;"
        DataSourceID="SqlDataSource1" DataTextField="Description" DataValueField="ID"
        onselectedindexchanged="SpaceType_SelectedIndexChanged"
        AutoPostBack="True">
     </telerik:RadComboBox>
     <div style="width: 231px; height: 31px; position: absolute; top: 525px; left: 13px; z-index: 1;">
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:UserConn %>"
        SelectCommand="SELECT ID,Description from SpaceTypes order by ID">
    </asp:SqlDataSource>
  </div>
     </form>
</body>
</html>

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Code Behind!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

using System;
using System.Web.UI.WebControls;
using System.Data;
using Telerik.Web.UI;
using System.Data.SqlClient;
using System.Configuration;
using System.IO;

public partial class ESManager : System.Web.UI.Page
{
    DataSet ds = new DataSet();
    
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            
        }
        else
        {
            foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
            {
                TextBox xControl = item["AttributeType"].FindControl("tb") as TextBox;
            }
        }
    }

    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        try
        {
            if (e.Item is GridDataItem)
            {

                int idex = Convert.ToInt32(e.Item.ItemIndexHierarchical);
                string type = ds.Tables[0].Rows[idex]["type"].ToString();

                Label LabelControl = new Label();
                LabelControl.ID = "l1";
                LabelControl.Text = ds.Tables[0].Rows[idex].ItemArray[0].ToString();
                LabelControl.Width = 200;
                GridDataItem item = e.Item as GridDataItem;
                item["AttributeType"].Controls.Add(LabelControl);

                if (type.ToLower() == "textbox")
                {
                    
                        TextBox xControl = new TextBox();
                        xControl.ID = "tb";
                        xControl.Text = "";
                        try { xControl.ToolTip = ds.Tables[0].Rows[idex]["doc"].ToString(); }
                        catch { }
                        xControl.Width = 75;
                        xControl.MaxLength = 7;
                        xControl.ValidationGroup = "GridControls";
                        item["AttributeType"].Controls.Add(xControl);

                        RequiredFieldValidator validator = new RequiredFieldValidator();
                        validator.ControlToValidate = xControl.ID;
                        validator.ErrorMessage = "*";

                }
                if (type.ToLower() == "listbox")
                {
                    DropDownList xControl = new DropDownList();
                    xControl.ID = "lb1";
                    string[] items = ds.Tables[0].Rows[idex]["items"].ToString().Split(',');
                    foreach (string xitem in items)
                    {
                        xControl.Items.Add(xitem);
                    }
                    xControl.SelectedValue = items[0];
                    xControl.ValidationGroup = "GridControls";
                    item["AttributeType"].Controls.Add(xControl);
                }
            }
        }
        catch (Exception ex)
        {
        }
    }
    
    protected void SpaceType_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["UserConn"].ToString()))
        {
            SqlCommand cmd = new SqlCommand("SELECT xmlTemplate from SpaceTypes where id=@ID", conn);

            cmd.Parameters.AddWithValue("@ID", SpaceType.SelectedValue.ToString());

            conn.Open();
            SqlDataReader reader = cmd.ExecuteReader();

            if (reader.Read())
            {
                try
                {
                    StringReader strReader = new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + reader["xmlTemplate"].ToString());

                    ds.ReadXml(strReader, XmlReadMode.InferSchema);
                    RadGrid1.DataSource = ds;
                    RadGrid1.DataBind();
                }
                catch (Exception ex)
                {
                }
            }
        }
    }

 
    protected void Button1_Click(object sender, EventArgs e)
    {
 
    }
}

JJ
Top achievements
Rank 2
 answered on 25 Jul 2014
5 answers
1.1K+ views
Hello, I have a RadGrid with multiples textboxes to be edited.
When i made "submit" (Postback on page) i lose all values inserted on that textboxes because RadGrid loses is values.

How can i solve this problem?

Any solution?
Thanks, Bruno F.
JJ
Top achievements
Rank 2
 answered on 25 Jul 2014
3 answers
309 views
I have been following your examples and created a RadGrid very similar to http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/usercontroleditform/defaultcs.aspx

in EditFormSettings I use PopUpSettings-Modal="true" and then <FormTemplate> I list a number of text boxes.

One of these text boxes is for a datetime field. I would like it so that when the user clicks "add new record" and the pop up shows up that in the form in this text box is prepopulated with the current date. I can't seem to get this working. This is my code:

protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
        {
            String strDate = DateTime.Today.ToString(); 
if (e.CommandName == RadGrid.InitInsertCommandName) //Runs when "Add new" button clicked
        {
                //Code to prepopulate field (But Doesn't Work)
GridCommandItem item = (GridCommandItem)e.Item; /*If I try with data item I get error: Unable to cast object of type 'Telerik.Web.UI.GridCommandItem' to type 'Telerik.Web.UI.GridDataItem'. */
TextBox txtname = (TextBox)item.FindControl("txtDate"); //txtDate is the name of the txtbox I want to prepopulate
txtname.Text = strDate;
}

However because its in a pop up it can't find the control and I get error: "NullReferenceException was unhandled by usercode, Object reference not set to an instance of an object."
Is this(Prepopulating a form template textbox inside a popup) even possible to do?... If so how?... Thank You
Sai
Top achievements
Rank 1
 answered on 25 Jul 2014
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?