Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
105 views
I want to create a RadGrid bulk editing by code behide. In GridDataItem have TextBox to show data in my datasource and it's can change data in textbox. Then after I press button save it's will read every data in TextBox in RadGrid and save changed data to datasource.

I will try to make my program like this by using GridTemplateColumn (in programmatic) I can bind data to textbox in TemplateColumn but when I press save button.... Textbox in RadGrid are disappear o_O!!. I don't know what's going on. Please help me I'm so tried to fine solution :'(
Jadesada
Top achievements
Rank 1
 answered on 18 Oct 2011
3 answers
118 views
I am trying to access the calculated aggregate value as I want to use the calculated value as the value of the cell. I can see their are some private items but I can not access them server side. Is there any way to achieve this?
Mira
Telerik team
 answered on 18 Oct 2011
3 answers
163 views
I want to be able to skin my Telerik RadControls on my asp.net page on the fly.
To do this I've made sure all these controls have an ID that starts "Rad" and when the page loads I have a method that cycles through all controls on a page and creates a List<Control> of those starting with "Rad".

Now all I need to do is cycle through my list and set the skin property to my selected skin. However, Control has no concept of "Skin" so I am trying to cast each of these to RadControl but am getting errors when casting, such as

Unable to cast object of type 'Telerik.Web.UI.RadPanelBar' to type 'Telerik.Web.UI.RadControl'.

My Code below...

protected void SetSkins(string colorScheme)
{
    List<Control> RadControls = new List<Control>();
    LoopControls(this.Page.Controls, ref RadControls);
  
    foreach (Control c in RadControls)
    {
        ((RadControl)c).Skin = colorScheme;
    }
}
  
  
public void LoopControls(ControlCollection controls, ref List<Control> RadControls)
{
    string output = string.Empty;
    foreach (Control control in controls)
    {
        if (!string.IsNullOrEmpty(control.ID) && control.ID.StartsWith("Rad"))
        {
            RadControls.Add(control);
        }
        LoopControls(control.Controls, ref RadControls);
    }
}

I suppose I could pass the skin name across and set the skin in the LoopControls method, but would still like an answer to my question.



Stuart Hemming
Top achievements
Rank 2
 answered on 18 Oct 2011
3 answers
381 views
Hi,

I have a radGrid to which I am trying to export using standard radGrid export options. But I am have few issues as below:

1) Export to CSV is not giving me data.
2) Export to Excel is giving data with extra columns.
3) Export to PDF is giving data with extra columns.

I am using the following code to do the same. Please let me know what the issue is.

ExportRadGrid.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ExportRadGrid.aspx.cs" Inherits="ExportRadGrid" %>
<%@ 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>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <telerik:RadScriptManager ID="scrip" runat="server"></telerik:RadScriptManager>
     <telerik:RadGrid ID="radGrid" runat="server" AutoGenerateColumns="false" AllowPaging="true"
                AllowSorting="true" AllowCustomPaging="true" PageSize="5" AllowFilteringByColumn="true"
               Skin="Office2007">
                <PagerStyle Mode="NextPrevNumericAndAdvanced" AlwaysVisible="true" />
               
            </telerik:RadGrid>
            
            <asp:Button ID="btnCSV" Text="CSV" runat="server" OnClick="btnCSV_Click"/>
            <asp:Button ID="btnExcel" Text="Excel" runat="server" OnClick="btnExcel_Click"/>
            <asp:Button ID="btnPDF" Text="PDF" runat="server" OnClick="btnPDF_Click"/>
    </div>
    </form>
</body>
</html>


ExportRadGrid.aspx.cs

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Telerik.Web.UI;

public partial class ExportRadGrid : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
         GridTemplateColumn column1 = new GridTemplateColumn();
            column1.UniqueName = "RollNo";
            column1.HeaderText = "RollNo";
            column1.ItemTemplate = new LabelTemplate("RollNo", string.Empty);

            GridTemplateColumn column2 = new GridTemplateColumn();
            column2.UniqueName = "Name";
            column2.HeaderText = "Name";
            column2.ItemTemplate = new LabelTemplate("Name", string.Empty);

            GridTemplateColumn column3 = new GridTemplateColumn();
            column3.UniqueName = "Address";
            column3.HeaderText = "Address";
            column3.ItemTemplate = new LabelTemplate("Address", string.Empty);


            radGrid.MasterTableView.Columns.Add(column1);
            radGrid.MasterTableView.Columns.Add(column2);
            radGrid.MasterTableView.Columns.Add(column3);

            radGrid.DataSource = GetDataTable();
            radGrid.DataBind();
        
    }

    protected void btnCSV_Click(object sender, EventArgs e)
    {
        SetReportSettings();
        radGrid.MasterTableView.ExportToCSV();
    }
    protected void btnExcel_Click(object sender, EventArgs e)
    {
        SetReportSettings();
        radGrid.MasterTableView.ExportToExcel();
    }
    protected void btnPDF_Click(object sender, EventArgs e)
    {
        SetReportSettings();
        radGrid.MasterTableView.ExportToPdf();
    }

    private void SetReportSettings()
    {
        this.radGrid.ExportSettings.ExportOnlyData = true;
        this.radGrid.ExportSettings.IgnorePaging = true;
        this.radGrid.ExportSettings.OpenInNewWindow = true;
    }

    private DataTable GetDataTable()
    {
        DataTable dt = new DataTable("MyTable");
        dt.Columns.Add("RollNo");
        dt.Columns.Add("Name");
        dt.Columns.Add("Address");

        DataRow dr1 = dt.NewRow();
        dr1["RollNo"] = 1;
        dr1["Name"] = "Mahesh";
        dr1["Address"] = "Addr1";


        DataRow dr2 = dt.NewRow();
        dr2["RollNo"] = 1;
        dr2["Name"] = "Kishore";
        dr2["Address"] = "Addr2";


        DataRow dr3 = dt.NewRow();
        dr3["RollNo"] = 1;
        dr3["Name"] = "Rajesh";
        dr3["Address"] = "Addr3";

        dt.Rows.Add(dr1);
        dt.Rows.Add(dr2);
        dt.Rows.Add(dr3);

        return dt;



    }
}

public class LabelTemplate : ITemplate
{
    public string DataField { get; set; }
    public string DataFormat { get; set; }

    private LabelTemplate()
    {
    }

    public LabelTemplate(string dataField, string dataFormat)
    {
        DataField = dataField;
        DataFormat = dataFormat;
    }

    #region ITemplate Members

    public void InstantiateIn(Control container)
    {
        Label label = new Label();
        label.DataBinding += new EventHandler(Label_DataBinding);
        container.Controls.Add(label);
    }

    void Label_DataBinding(object sender, EventArgs e)
    {
        Label label = (Label)sender;
        GridDataItem container = (GridDataItem)label.NamingContainer;
        if (DataFormat != string.Empty)
            label.Text = string.Format(DataFormat, ((DataRowView)container.DataItem)[DataField].ToString());
        else
            label.Text = ((DataRowView)container.DataItem)[DataField].ToString();
    }

    #endregion
}



Thanks,
Mahesh


Daniel
Telerik team
 answered on 18 Oct 2011
1 answer
73 views
Hello,

I have a radmenu in aspx page and i am adding radsitemap dynamically to radmenuitem.
I am adding radsitemapnodes to radsitemap.
I am using IE9, if i run my application in compatible mode then it works fine.
OR
If i add <meta http-equiv="X-UA-Compatible" content="IE=8" />  in the HEAD section then also it works fine.
In the above two scenarios i was able to see radsitemapnodes with bullets on the left side.
But, if i open my application in normal mode in IE9,then whenever i hover on the menuitem i can see the text of the radsitemapnodes but
the bullets are invisible.
if i click on the menu or if i do some click action on the menu then all bullets are visible .From then i was able to see the bullets in the
Radsitemap.

Does anybody aware of this issue.
Is this the issue with IE9?
Is there any workaround for this?

Please assist.

Thanks,
LV
Peter
Telerik team
 answered on 18 Oct 2011
1 answer
126 views
I'm using a radmenu next to a radcombobox to dynamically show a menu depending on the selected value of the ComboBox using a webservice.

So far so good, except that it looks horrible when I have a multiline menu item.  

The hover over image adds 3 lines to each item and I can't remove it.  

It would be ideal to add an item template to each menu item inside of the webservice, but I can't find any propery of the radmenuitemdata object that accepts a template.

Please help.
Kate
Telerik team
 answered on 18 Oct 2011
1 answer
134 views
Hi,

how to disable text box when i am using rasnUploadCompanyLogo.Enabled = false;

Button and text box  get disable but user still can write some text which is wrong.

Suggest please, How i will stop to write if it is disable.

Thanks ,
Reyaz


Please look the following url:
http://www.telerik.com/community/forums/aspnet-ajax/upload/how-to-disable-focus-from-textbox-in-radupload.aspx
Peter Filipov
Telerik team
 answered on 18 Oct 2011
7 answers
551 views
Hi,

I am having problem in disabling the focus from the textbox of this RadUpload Control. We got this as a usuability bug from our test team. Can anyone help?

Thanks,

Sharad
Peter Filipov
Telerik team
 answered on 18 Oct 2011
2 answers
220 views
Hi,

I am opening a rad window from javascript but it opens with parent page reload.

 function OpenAddNewDocument() {
            window.radopen("AddNewDocument.aspx", "rwAddNewDocument");
            return false;
        }


<input id="btnAddDoc" type="button" value="Add New Document" class="btnAddDoc" title="Add New Document" runat="server"
           onClick="return OpenAddNewDocument();" />


Please help to open this window without postback.


Thanks
Manish.
Manish
Top achievements
Rank 2
 answered on 18 Oct 2011
2 answers
255 views
I have the following RadGrid:

<telerik:RadGrid ID="uxFacilityUsage" runat="server" AllowSorting="True"
        AutoGenerateColumns="False" GridLines="None"
        onneeddatasource="uxFacilityUsage_NeedDataSource" ShowGroupPanel="True"
        onitemdatabound="uxFacilityUsage_ItemDataBound"
        onitemcommand="uxFacilityUsage_ItemCommand" AllowPaging="True"
        PageSize="20" AllowFilteringByColumn="True"
        ongroupschanging="uxFacilityUsage_GroupsChanging">
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>
<GroupPanel Text="Drag a column header and drop it here to group by that column."></GroupPanel>
 
<AlternatingItemStyle CssClass="AlternatingRowStyle"></AlternatingItemStyle>
 
<PagerStyle Mode="NextPrevNumericAndAdvanced"></PagerStyle>
<ExportSettings>
    <Pdf PageLeftMargin="0.5in" PageRightMargin="0.5in" />
</ExportSettings>
<MasterTableView CommandItemDisplay="Top" IsFilterItemExpanded="false">
 
<SortExpressions>
                <telerik:GridSortExpression FieldName="StartDate" SortOrder="Descending" />
            </SortExpressions>
<CommandItemSettings ExportToPdfText="Export to Pdf" ShowAddNewRecordButton="False"
        ShowExportToPdfButton="True"></CommandItemSettings>
<GroupByExpressions>
<telerik:GridGroupByExpression>
    <SelectFields>
        <telerik:GridGroupByField FieldName="CylinderType" Aggregate="Count"/>
    </SelectFields>
    <GroupByFields>
        <telerik:GridGroupByField FieldName="CylinderType" FormatString="{0:0}"/>
    </GroupByFields>
</telerik:GridGroupByExpression>
</GroupByExpressions>
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
 
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
    <Columns>
        <telerik:GridBoundColumn DataField="LotNumber"
            FilterControlAltText="Filter LotNumber column" HeaderText="LotNumber"
            SortExpression="LotNumber" UniqueName="LotNumber">
            <HeaderStyle Width="150px" />
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="CylinderType"
            FilterControlAltText="Filter CylinderType column" HeaderText="Cylinder Type"
            SortExpression="CylinderType" UniqueName="CylinderType">
            <HeaderStyle Width="100px" />
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="GasType"
            FilterControlAltText="Filter GasType column" HeaderText="Gas Type"
            SortExpression="GasType" UniqueName="GasType">
            <HeaderStyle Width="100px" />
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Facility"
            FilterControlAltText="Filter Facility column" HeaderText="Facility"
            SortExpression="Facility" UniqueName="Facility" Visible="False">           
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="StartDate"
            DataType="System.DateTime"
            FilterControlAltText="Filter StartDate column"
            HeaderText="Start Date" SortExpression="StartDate"
            UniqueName="StartDate">
            <HeaderStyle Width="150px" />
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="PatientName"
            FilterControlAltText="Filter PatientName column" HeaderText="Patient"
            ReadOnly="True" SortExpression="PatientName" UniqueName="PatientName">
            <HeaderStyle Width="120px" />
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="PayerType"
            FilterControlAltText="Filter PatientName column" HeaderText="Payer Type"
            ReadOnly="True" SortExpression="PayerType" UniqueName="PayerType">
            <HeaderStyle Width="100px" />
        </telerik:GridBoundColumn>         
        <telerik:GridBoundColumn DataField="RoomNumber"
            FilterControlAltText="Filter RoomNumber column" HeaderText="Room"
            SortExpression="RoomNumber" UniqueName="RoomNumber">
            <HeaderStyle Width="50px" />
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="BedAssignment"
            FilterControlAltText="Filter BedAssignment column" HeaderText="Bed"
            SortExpression="BedAssignment" UniqueName="BedAssignment">
            <HeaderStyle Width="100px" />
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Location"
            FilterControlAltText="Filter Location column" HeaderText="Location"
            SortExpression="Location" UniqueName="Location">
            <HeaderStyle Width="150px" />
        </telerik:GridBoundColumn>      
        <telerik:GridBoundColumn DataField="FacilityUsername"
            FilterControlAltText="Filter FacilityUsername column"
            HeaderText="Assigned By" ReadOnly="True" SortExpression="FacilityUsername"
            UniqueName="FacilityUsername">
        </telerik:GridBoundColumn>
    </Columns>
 
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
</EditFormSettings>
</MasterTableView>
 
<GroupingSettings ShowUnGroupButton="True"></GroupingSettings>
 
        <ClientSettings AllowDragToGroup="True">
 
<Resizing AllowColumnResize="True" EnableRealTimeResize="True"></Resizing>
        </ClientSettings>
 
<FilterMenu EnableImageSprites="False"></FilterMenu>
     
    </telerik:RadGrid>

And my NeedDataSource:

using (var context = new DataContext(SqlHelper.NewConnection))
{
    var results = context.ReportCylinderFacilityUsage(Master.FacilitySelection.SelectedValue);
     uxFacilityUsage.DataSource = results.ToList();
}

ReportCylinderFacilityUsage is a stored procedure.  One of the columns it returns is CylinderType

What I'd like to do is group by CylinderType and have the Count for each type of Cylinder displayed in the header.

When I have the following set up in the GroupBy Expressions:
<telerik:GridGroupByExpression>
    <SelectFields>
        <telerik:GridGroupByField FieldName="CylinderType" />
    </SelectFields>
    <GroupByFields>
        <telerik:GridGroupByField FieldName="CylinderType" Aggregate="Count" />
    </GroupByFields>
</telerik:GridGroupByExpression>
I get an error: FieldName contains invalid characters: count(CylinderType)

if I put the Aggregate on the SelectField then I get the error: A column named "CylinderType" already belongs to this datatable.


Thanks,

Jason
Radoslav
Telerik team
 answered on 18 Oct 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Top achievements
Rank 1
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ivory
Top achievements
Rank 1
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
YF
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Top achievements
Rank 1
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ivory
Top achievements
Rank 1
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
YF
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?