Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
81 views
This is not a telerik specific query. When I select the text by double clicking or click and dragging, How can I get the selected text in js? 

Thankyou
Robert
Shinu
Top achievements
Rank 2
 answered on 19 Sep 2013
1 answer
408 views
I am trying to use the insert button to insert a record into my datatable, i have the following code that i tried, but when i click on the insert button nothing happens, it just seems to refresh the page, can someone please help me out:

ususing System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using System.ComponentModel;
 
public partial class Default5 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["GridData"] == null)
        {
            DataTable table = GetTable();
            Session.Add("GridData", table);
        }
        DefineGridStructure();
    }
 
 
    private void DefineGridStructure()
    {
        RadGrid grid = new RadGrid();
        grid.ID = "RadGrid1";
        grid.NeedDataSource += new GridNeedDataSourceEventHandler(grid_NeedDataSource);
        grid.AutoGenerateEditColumn = true;
        grid.AutoGenerateDeleteColumn = true;
        grid.AllowAutomaticInserts = true;
        grid.Width = Unit.Percentage(100);
        grid.PageSize = 15;
        grid.AllowPaging = true;
        grid.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric;
        grid.AutoGenerateColumns = false;
        grid.MasterTableView.Width = Unit.Percentage(100);
        grid.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.TopAndBottom;
        grid.ItemInserted += grid_ItemInserted;
         
        grid.MasterTableView.DataKeyNames = new string[] { "RowNumber" };
        GridBoundColumn boundColumn = new GridBoundColumn();
        boundColumn.DataField = "RowNumber";
        boundColumn.HeaderText = "RowNumber";
        boundColumn.ReadOnly = true;
        grid.MasterTableView.Columns.Add(boundColumn);
        boundColumn = new GridBoundColumn();
        boundColumn.DataField = "Size";
        boundColumn.HeaderText = "Size";
        grid.MasterTableView.Columns.Add(boundColumn);
        boundColumn = new GridBoundColumn();
        boundColumn.DataField = "Description";
        boundColumn.HeaderText = "Description";
        grid.MasterTableView.Columns.Add(boundColumn);
        boundColumn = new GridBoundColumn();
        boundColumn.DataField = "Quantity";
        boundColumn.HeaderText = "Quantity";
        grid.MasterTableView.Columns.Add(boundColumn);
        boundColumn = new GridBoundColumn();
        boundColumn.DataField = "Duration";
        boundColumn.HeaderText = "Duration";
        grid.MasterTableView.Columns.Add(boundColumn);
        boundColumn = new GridBoundColumn();
        boundColumn.DataField = "DurationType";
        boundColumn.HeaderText = "DurationType";
        grid.MasterTableView.Columns.Add(boundColumn);
        boundColumn = new GridBoundColumn();
        boundColumn.DataField = "Amount";
        boundColumn.HeaderText = "Amount";
        grid.MasterTableView.Columns.Add(boundColumn);
        PlaceHolder1.Controls.Add(grid);
    }
 
    private void grid_ItemInserted(object sender, GridInsertedEventArgs e)
    {
        RadGrid grid = (RadGrid)sender;
        int rowIndex = 0;
        if (Session["GridData"] != null)
        {
            DataTable dtCurrentTable = (DataTable)Session["GridData"];
            DataRow drCurrentRow = null;
 
            if (dtCurrentTable.Rows.Count > 0)
            {
                for (int i = 0; i < dtCurrentTable.Rows.Count; i++)
                {
 
                    GridEditFormInsertItem item = e.Item as GridEditFormInsertItem;
                    TextBox box1 = item.FindControl("Size") as TextBox;
                    TextBox box2 = item.FindControl("Description") as TextBox;
                    TextBox box3 = item.FindControl("Quantity") as TextBox;
                    TextBox box4 = item.FindControl("Unit") as TextBox;
                    TextBox box5 = item.FindControl("Duration") as TextBox;
                    TextBox box6 = item.FindControl("DurationType") as TextBox;
                    TextBox box7 = item.FindControl("Amount") as TextBox;
 
                    drCurrentRow = dtCurrentTable.NewRow();
                    drCurrentRow["RowNumber"] = i + 1;
                    dtCurrentTable.Rows[i - 1]["Size"] = box1.Text;
                    dtCurrentTable.Rows[i - 1]["Description"] = box2.Text;
                    dtCurrentTable.Rows[i - 1]["Quantity"] = box3.Text;
                    dtCurrentTable.Rows[i - 1]["Unit"] = box4.Text;
                    dtCurrentTable.Rows[i - 1]["Duration"] = box5.Text;
                    dtCurrentTable.Rows[i - 1]["DurationType"] = box6.Text;
                    dtCurrentTable.Rows[i - 1]["Amount"] = box7.Text;
                    rowIndex++;
 
                }
                dtCurrentTable.Rows.Add(drCurrentRow);
                Session["GridData"] = dtCurrentTable;
                grid.DataSource = Session["GridData"];
                grid.Rebind();
            }
        }
    }
 
 
 
    void grid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        DataTable current = (DataTable)Session["GridData"];
        RadGrid grid = (RadGrid)sender;
        grid.DataSource = current;
    }
 
 
 
    static DataTable GetTable()
    {
        //
        // Here we create a DataTable with a few columns.
        //
        // Create Datatable to store all colums
        DataTable dt = new DataTable();
        DataRow dr = null;
        dt.Columns.Add(new DataColumn("RowNumber", typeof(string)));
        dt.Columns.Add(new DataColumn("Size", typeof(string)));
        dt.Columns.Add(new DataColumn("Description", typeof(string)));
        dt.Columns.Add(new DataColumn("Quantity", typeof(string)));
        dt.Columns.Add(new DataColumn("Unit", typeof(string)));
        dt.Columns.Add(new DataColumn("Duration", typeof(string)));
        dt.Columns.Add(new DataColumn("DurationType", typeof(string)));
        dt.Columns.Add(new DataColumn("Amount", typeof(string)));
        dr = dt.NewRow();
        dr["RowNumber"] = 1;
        dr["Size"] = string.Empty;
        dr["Description"] = string.Empty;
        dr["Quantity"] = string.Empty;
        dr["Unit"] = string.Empty;
        dr["Duration"] = string.Empty;
        dr["DurationType"] = string.Empty;
        dr["Amount"] = string.Empty;
        dt.Rows.Add(dr);
        return dt;
    }
 
}
Eyup
Telerik team
 answered on 19 Sep 2013
5 answers
246 views
Hi,
How can I get the masked text from a RadNumericTextBox?
For example...

// RadTextBox
RadNumericTextBox rntb = new RadNumericTextBox();
rntb.NumberFormat.PositivePattern = "n%";
rntb.NumberFormat.DecimalDigits = 0;
rntb.MinValue = 0;
rntb.MaxValue = 100;
rntb.Text = 50; // Displays as "50%"
 
// How do I get "50%" into a label?
Label lbl = new Label();
lbl.Text = rntb.Text; // Only shows "50". I want to show "50%"

In the above example, how can I get the masked value "50%"?
TextWithLiterals would be great but only applies to RadMaskedTextBox. 

Thanks!
Joe
Top achievements
Rank 2
 answered on 19 Sep 2013
1 answer
179 views
Here is the link I posted on the asp.net: 

http://forums.asp.net/t/1935517.aspx?Load+userControl+first+time+get+called+and+load+properly+Page_Load+then+click+on+the+Sorting+or+pageSize+changed+on+the+RadGrid+that+control+did+not+load

Here is my iTemplate class: 
        public class iTemplate : ITemplate
        {
            private string columnName;
            Page page; 

            public iTemplate(string cName, Page page)
            {
                columnName = cName;
                this.page =page; 
            }

            public void InstantiateIn(System.Web.UI.Control container)
            {
                Control ctrl = new Control();
                
                //System.Web.UI.
                
                //MWStringCrtl mwstringCtrl = (MWStringCrtl)loadMwstringCtrl();
                MWStringCrtl mwstringCtrl = (MWStringCrtl)page.LoadControl("~/ServiceModules/Controls/MWStringCrtl.ascx");
                mwstringCtrl.Wrapper = new MWStringCrtl.DataWrapper();
                mwstringCtrl.ID =container.ClientID+ "_mctrl";
                mwstringCtrl.DataBinding += new EventHandler(this.BindData);
                mwstringCtrl.Wrapper.ValueOnNewLine = false;
                mwstringCtrl.Wrapper.ValueFontSize = 12;
                SimpleStringDto blankCell = new SimpleStringDto();
                blankCell.Text = "hello";

                mwstringCtrl.Wrapper.Data = blankCell; 
                container.Controls.Add(mwstringCtrl);
            }


            public void BindData(object sender, EventArgs e)
            {
                MWStringCrtl mc = (MWStringCrtl)sender;
                GridDataItem container = (GridDataItem)mc.NamingContainer;
                mc.Wrapper = (MWStringCrtl.DataWrapper)((RowDataWrapper)container.DataItem).GetType().GetProperty(columnName).GetValue((RowDataWrapper)container.DataItem, null);
            }
        }

when load the Grid first time, first instantiateIn the User control and bind the data, and lastly Page_Load the dynamically user control. 

However, when Sorting or paging, first Instantiateln the User control and Page_Load the dynamically User Control, and last Bind the Data, which in result will have the empty Grid. 

anybody can help, it is urgent? 

Thanks,T
Eyup
Telerik team
 answered on 19 Sep 2013
7 answers
108 views
Duplicate insert problem.

I insert an item and after the insert successfully happens I call:

RadGridOperators.MasterTableView.IsItemInserted = false;
e.Canceled = true;
RadGridOperators.MasterTableView.ClearEditItems();
RadGridOperators.MasterTableView.Rebind();

The edit form does in deed close but if I hit the refresh button on the web browser the insert happens again (EVEN THOUGH THE EDIT FORM IS NOT OPEN). How can I avoid this behavior??
Eyup
Telerik team
 answered on 19 Sep 2013
2 answers
85 views
Hi,
i am using rad window to show errors or success but i want
1] only close and pin button
2] Dont want scrolling
2] Dont want last Section(splitted part) of window

My code and screenshot is
<telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true">
    </telerik:RadWindowManager>
    <telerik:RadWindow ID="radwindowPopup" runat="server" Animation="FlyIn" CssClass="modalPopup"
        DestroyOnClose="true" EnableShadow="true" IconUrl="~/Images/Bi.ico" KeepInScreenBounds="true"
        Width="420px" Height="150px" MaxHeight="150px" MaxWidth="420px" MinHeight="150px"
        MinWidth="420px" Modal="true" RenderMode="Classic" VisibleStatusbar="true" VisibleTitlebar="true"
        Behaviors="Close" Title="Manifest-BI" Skin="Web20">
        <ContentTemplate>
            <center>
                <div style="padding: 20px">
                    Are you sure you want to Delete this Record?
                    <br />
                    <br />
                    <telerik:RadButton ID="btnOk" runat="server" Text="Yes" Width="70px" OnClick="btnOk_Click"
                        Skin="Web20" />
                        
                    <telerik:RadButton ID="btnCancel" runat="server" Text="No" Width="70px" OnClick="btnCancel_Click"
                        Skin="Web20" />
                </div>
            </center>
        </ContentTemplate>
    </telerik:RadWindow>
and

Swapnil
Top achievements
Rank 1
 answered on 19 Sep 2013
2 answers
114 views
Entering characters \ / or ; and then clicking "save change" crashes the demo at
batchediting demo
(says page not available)

Saving multiline text also doesnt work. e.Commands in  RadGrid1_BatchEditCommand is empty.
Since this looks like a bug in ur control and I need workaround can you plz tell me how can i save updated text manually to database when user presses save changes button?

Also it would be very nice if save button would become enabled only when any changes have been made to the grid. Any easy way I can change that?
Angel Petrov
Telerik team
 answered on 19 Sep 2013
1 answer
66 views
Hi All,

I get the attached message when I am trying to upload images or manage images using the imagemanager part of the editor.

I have checked my permission (I also have created the directory at runtime to ensure there isnt an issue) and I still get the error.

I have seen the same error happen on this page

http://demos.telerik.com/aspnet-ajax/editor/examples/dbfilebrowsercontentprovider/defaultcs.aspx when using the image manager part.

The error makes no sense as I can still view and upload files, I just get this annoying message come up

Please help

Thanks

Nathan
Ianko
Telerik team
 answered on 19 Sep 2013
5 answers
115 views
I added my comments to the forum.

http://www.telerik.com/community/forums/aspnet-ajax/grid/refresh-radgrid-after-insert-causes-another-insert.aspx#2789395


I need some response asap.

thanks
Eyup
Telerik team
 answered on 19 Sep 2013
1 answer
85 views

I know we can perform calculations and add them to a group header:

Private Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs)
 
    If TypeOf e.Item Is GridGroupHeaderItem Then
        Dim item As GridGroupHeaderItem = CType(e.Item, GridGroupHeaderItem)
        Dim groupDataRow As DataRowView = CType(e.Item.DataItem, DataRowView)
        item.DataCell.Text = (item.DataCell.Text + "; Avg: ")
        item.DataCell.Text = (item.DataCell.Text + (CType(groupDataRow("total"), Decimal) / Integer.Parse(groupDataRow("count").ToString)).ToString)
    End If
End Sub

But is there a way to just add the Column aggregate:
<telerik:GridBoundColumn DataField="Subject" FilterControlAltText="Filter Subject column"
HeaderText="Subject" SortExpression="Subject" UniqueName="Subject" ItemStyle-HorizontalAlign="Left"
FooterStyle-HorizontalAlign="Left" FooterText="Tickets " Aggregate="Count">
</telerik:GridBoundColumn>

Thank you in advance.




Kostadin
Telerik team
 answered on 19 Sep 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?