Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
121 views
I am using the Copy and Paste example mentioned in this thread (and in other copy and paste threads). The only thing that I change is to set AutoGenerateColumns="False" and list down the columns. Everything works like the original example.

Code that works:
ASPX
<telerik:RadCodeBlock ID="rcb1" runat="server">
    <script type="text/javascript">
         
        // ***** Begin Paste from Excel scripts.
        var lastFocused;
 
        function pasteFromExcel() {
            if (!lastFocused) return;
            var clipData = window.clipboardData.getData('Text');
            var crlf = String.fromCharCode(13) + String.fromCharCode(10);
            var table = clipData.split(crlf);
            for (var tRow = 0; tRow < table.length - 1; tRow++)
                table[tRow] = table[tRow].split(String.fromCharCode(9));
            Array.remove(table, table[table.length - 1]);
            fillTable(table);
        }
 
        function fillTable(table) {
            var pCell = lastFocused.parentNode;
            var pRow = pCell.parentNode;
            var pBody = pRow.parentNode;
            var maxRows = pBody.rows.length;
            var maxCols = pRow.cells.length;
 
            hasChanges = true;
            for (var row = 0; row < table.length; row++) {
                for (var col = 0; col < table[row].length; col++) {
                    var cCellIndex = pCell.cellIndex + col;
                    var cRowIndex = pRow.sectionRowIndex + row;
 
                    if (cRowIndex < maxRows && cCellIndex < maxCols) {
                        var cCell = pBody.rows[cRowIndex].cells[cCellIndex];
                        var pInput = cCell.getElementsByTagName("input")[0];
 
                        pInput.style.backgroundColor = "#F7FAFF";
                        pInput.value = table[row][col];
                    }
                }
            }
        }
 
        function gridFocus(e) {
            e = e || window.event;
            var target = e.target || e.srcElement;
            if (target.tagName.toLowerCase() == "input" && target.type.toLowerCase() == "text")
                lastFocused = target;
        }
 
        function clearCells(sender) {
            var radGrid = $get('<%= RadGrid1.ClientID %>');
            var inputs = radGrid.getElementsByTagName("input");
            for (var el = 0; el < inputs.length; el++) {
                if (inputs[el].type == "text") {
                    inputs[el].value = "";
                    inputs[el].style.backgroundColor = "";
                }
            }
        }
        // ***** End Paste from Excel scripts.
 
 
    </script>
 
</telerik:RadCodeBlock>
<div>
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
        <telerik:RadGrid ID="RadGrid1" runat="server" AllowMultiRowEdit="true" DataSourceID="SqlDataSource1"
            onclick="gridFocus(event)" Width="830px" ShowHeader="true" Skin="Office2007" OnColumnCreated="RadGrid1_ColumnCreated"
            AllowAutomaticUpdates="true" OnItemUpdated="RadGrid1_ItemUpdated" AutoGenerateColumns="False">
            <MasterTableView EditMode="InPlace" CommandItemDisplay="Top" TableLayout="Fixed">
                <CommandItemTemplate>
                    <div style="float: left">
                        <input type="button" value="Paste from Excel" onclick="pasteFromExcel()" />
                        <input type="button" value="Clear cells" onclick="clearCells()" />
                    </div>
                    <div style="float: right">
                        <asp:Button ID="UpdateEditedButton" CommandName="UpdateEdited" Text="Update edited items"
                            runat="server" />
                    </div>
                </CommandItemTemplate>
                <Columns>
                    <telerik:GridBoundColumn DataField="ID" DataType="System.Int32"
                        HeaderText="ID" UniqueName="ID" Visible="true" ReadOnly="True">
                        <HeaderStyle HorizontalAlign="Center" />
                        <ItemStyle HorizontalAlign="Left" />
                    </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Column1"
                            HeaderText="Column1"
                            UniqueName="Column1" Visible="true">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Column2"
                            HeaderText="Column2"
                            UniqueName="Column2" Visible="true">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Column3"
                            HeaderText="Column3"
                            UniqueName="Column3" Visible="true">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Column4"
                            HeaderText="Column4"
                            UniqueName="Column4" Visible="true">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Column5"
                            HeaderText="Column5"
                            UniqueName="Column5" Visible="true">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Column6"
                            HeaderText="Column6"
                            UniqueName="Column6" Visible="true">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Column7"
                            HeaderText="Column7"
                            UniqueName="Column7" Visible="true">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Column8"
                            HeaderText="Column8"
                            UniqueName="Column8" Visible="true">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Column9"
                            HeaderText="Column9"
                            UniqueName="Column9" Visible="true">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Column10"
                            HeaderText="Column10"
                            UniqueName="Column10" Visible="true">
                        </telerik:GridBoundColumn>
                    </Columns>
            </MasterTableView>
        </telerik:RadGrid>
    </telerik:RadAjaxPanel>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>"
        DeleteCommand="DELETE FROM [EmptyTable] WHERE [ID] = @ID" InsertCommand="INSERT INTO [EmptyTable] ([ID], [Column1], [Column2], [Column3], [Column4], [Column5], [Column6], [Column7], [Column8], [Column9], [Column10]) VALUES (@ID, @Column1, @Column2, @Column3, @Column4, @Column5, @Column6, @Column7, @Column8, @Column9, @Column10)"
        SelectCommand="SELECT * FROM [EmptyTable]" UpdateCommand="UPDATE [EmptyTable] SET [Column1] = @Column1, [Column2] = @Column2, [Column3] = @Column3, [Column4] = @Column4, [Column5] = @Column5, [Column6] = @Column6, [Column7] = @Column7, [Column8] = @Column8, [Column9] = @Column9, [Column10] = @Column10 WHERE [ID] = @ID">
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="Column1" Type="String" />
            <asp:Parameter Name="Column2" Type="String" />
            <asp:Parameter Name="Column3" Type="String" />
            <asp:Parameter Name="Column4" Type="String" />
            <asp:Parameter Name="Column5" Type="String" />
            <asp:Parameter Name="Column6" Type="String" />
            <asp:Parameter Name="Column7" Type="String" />
            <asp:Parameter Name="Column8" Type="String" />
            <asp:Parameter Name="Column9" Type="String" />
            <asp:Parameter Name="Column10" Type="String" />
            <asp:Parameter Name="ID" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="ID" Type="Int32" />
            <asp:Parameter Name="Column1" Type="String" />
            <asp:Parameter Name="Column2" Type="String" />
            <asp:Parameter Name="Column3" Type="String" />
            <asp:Parameter Name="Column4" Type="String" />
            <asp:Parameter Name="Column5" Type="String" />
            <asp:Parameter Name="Column6" Type="String" />
            <asp:Parameter Name="Column7" Type="String" />
            <asp:Parameter Name="Column8" Type="String" />
            <asp:Parameter Name="Column9" Type="String" />
            <asp:Parameter Name="Column10" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>
</div>

.CS
protected void Page_Load(object sender, EventArgs e)
{
                for (int i = 0; i < RadGrid1.PageSize; i++)
                    RadGrid1.EditIndexes.Add(i);           
}
 
protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
{
     
    if (e.Column is GridBoundColumn)
        e.Column.Visible = (e.Column as GridBoundColumn).DataField != "ID";
     
}
 
protected void RadGrid1_ItemUpdated(object source, GridUpdatedEventArgs e)
{
    e.KeepInEditMode = true;
}

Now when I change the columns in the grid from GridBoundColumn to GridNumericColumn, here's what I find out:

1. There is an extra <span> element in the GridNumericColumn so I had to update function fillTable to go to an extra parentNode. The data is pasted on the correct cells but if you click on those cells, it removes the pasted data and reverts to the original data.

2. The edit cells changed from an inset border and each cell is slightly indented to a thin solid border where the first column is slightly indented and all succeeding columns mis-aligned. I can deal with the border style, I need to know how to remove the slight indent in the first column or at least make it look like the GridBoundColumn example.

    <telerik:RadCodeBlock ID="rcb1" runat="server">
        <script type="text/javascript">
             
            // ***** Begin Paste from Excel scripts.
            var lastFocused;
 
            function pasteFromExcel() {
                if (!lastFocused) return;
                var clipData = window.clipboardData.getData('Text');
                var crlf = String.fromCharCode(13) + String.fromCharCode(10);
                var table = clipData.split(crlf);
                for (var tRow = 0; tRow < table.length - 1; tRow++)
                    table[tRow] = table[tRow].split(String.fromCharCode(9));
                Array.remove(table, table[table.length - 1]);
                fillTable(table);
            }
 
            function fillTable(table) {
 
//Changed this line to the 2 lines below.
//                var pCell = lastFocused.parentNode;
 
                var pSpan = lastFocused.parentNode;
                var pCell = pSpan.parentNode;
 
                var pRow = pCell.parentNode;
                var pBody = pRow.parentNode;
                var maxRows = pBody.rows.length;
                var maxCols = pRow.cells.length;
 
                hasChanges = true;
                for (var row = 0; row < table.length; row++) {
                    for (var col = 0; col < table[row].length; col++) {
                        var cCellIndex = pCell.cellIndex + col;
                        var cRowIndex = pRow.sectionRowIndex + row;
 
                        if (cRowIndex < maxRows && cCellIndex < maxCols) {
                            var cCell = pBody.rows[cRowIndex].cells[cCellIndex];
                            var pInput = cCell.getElementsByTagName("input")[0];
 
                            pInput.style.backgroundColor = "#F7FAFF";
                            pInput.value = table[row][col];
                        }
                    }
                }
            }
 
            function gridFocus(e) {
                e = e || window.event;
                var target = e.target || e.srcElement;
                if (target.tagName.toLowerCase() == "input" && target.type.toLowerCase() == "text")
                    lastFocused = target;
            }
 
            function clearCells(sender) {
                var radGrid = $get('<%= RadGrid1.ClientID %>');
                var inputs = radGrid.getElementsByTagName("input");
                for (var el = 0; el < inputs.length; el++) {
                    if (inputs[el].type == "text") {
                        inputs[el].value = "";
                        inputs[el].style.backgroundColor = "";
                    }
                }
            }
            // ***** End Paste from Excel scripts.
 
 
        </script>
 
    </telerik:RadCodeBlock>
    <div>
        <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
            <telerik:RadGrid ID="RadGrid1" runat="server" AllowMultiRowEdit="true" DataSourceID="SqlDataSource1"
                onclick="gridFocus(event)" Width="830px" ShowHeader="true" Skin="Office2007" OnColumnCreated="RadGrid1_ColumnCreated"
                AllowAutomaticUpdates="true" OnItemUpdated="RadGrid1_ItemUpdated" AutoGenerateColumns="False">
                <MasterTableView EditMode="InPlace" CommandItemDisplay="Top" TableLayout="Fixed">
                    <editformsettings>
                        <editcolumn filtercontrolalttext="Filter EditCommandColumn column">
                        </editcolumn>
                    </editformsettings>
                    <CommandItemTemplate>
                        <div style="float: left">
                            <input type="button" value="Paste from Excel" onclick="pasteFromExcel()" />
                            <input type="button" value="Clear cells" onclick="clearCells()" />
                        </div>
                        <div style="float: right">
                            <asp:Button ID="UpdateEditedButton" CommandName="UpdateEdited" Text="Update edited items"
                                runat="server" />
                        </div>
                    </CommandItemTemplate>
                    <CommandItemSettings ExportToPdfText="Export to PDF" />
                    <rowindicatorcolumn filtercontrolalttext="Filter RowIndicator column"
                        visible="True">
                    </rowindicatorcolumn>
                    <expandcollapsecolumn filtercontrolalttext="Filter ExpandColumn column"
                        visible="True">
                    </expandcollapsecolumn>
                    <Columns>
                        <telerik:GridNumericColumn DataField="ID" DataType="System.Int32"
                            HeaderText="ID" UniqueName="ID" Visible="true" ReadOnly="True">
                        </telerik:GridNumericColumn>
                            <telerik:GridNumericColumn DataField="Column1"
                                HeaderText="Column1"
                                UniqueName="Column1" Visible="true">
                            </telerik:GridNumericColumn>
                            <telerik:GridNumericColumn DataField="Column2"
                                HeaderText="Column2"
                                UniqueName="Column2" Visible="true">
                            </telerik:GridNumericColumn>
                            <telerik:GridNumericColumn DataField="Column3"
                                HeaderText="Column3"
                                UniqueName="Column3" Visible="true">
                            </telerik:GridNumericColumn>
                            <telerik:GridNumericColumn DataField="Column4"
                                HeaderText="Column4"
                                UniqueName="Column4" Visible="true">
                            </telerik:GridNumericColumn>
                            <telerik:GridNumericColumn DataField="Column5"
                                HeaderText="Column5"
                                UniqueName="Column5" Visible="true">
                            </telerik:GridNumericColumn>
                            <telerik:GridNumericColumn DataField="Column6"
                                HeaderText="Column6"
                                UniqueName="Column6" Visible="true">
                            </telerik:GridNumericColumn>
                            <telerik:GridNumericColumn DataField="Column7"
                                HeaderText="Column7"
                                UniqueName="Column7" Visible="true">
                            </telerik:GridNumericColumn>
                            <telerik:GridNumericColumn DataField="Column8"
                                HeaderText="Column8"
                                UniqueName="Column8" Visible="true">
                            </telerik:GridNumericColumn>
                            <telerik:GridNumericColumn DataField="Column9"
                                HeaderText="Column9"
                                UniqueName="Column9" Visible="true">
                            </telerik:GridNumericColumn>
                            <telerik:GridNumericColumn DataField="Column10"
                                HeaderText="Column10"
                                UniqueName="Column10" Visible="true">
                            </telerik:GridNumericColumn>
                        </Columns>
                </MasterTableView>
                <filtermenu enableimagesprites="False">
                </filtermenu>
            </telerik:RadGrid>
        </telerik:RadAjaxPanel>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>"
            DeleteCommand="DELETE FROM [EmptyTable] WHERE [ID] = @ID" InsertCommand="INSERT INTO [EmptyTable] ([ID], [Column1], [Column2], [Column3], [Column4], [Column5], [Column6], [Column7], [Column8], [Column9], [Column10]) VALUES (@ID, @Column1, @Column2, @Column3, @Column4, @Column5, @Column6, @Column7, @Column8, @Column9, @Column10)"
            SelectCommand="SELECT * FROM [EmptyTable]" UpdateCommand="UPDATE [EmptyTable] SET [Column1] = @Column1, [Column2] = @Column2, [Column3] = @Column3, [Column4] = @Column4, [Column5] = @Column5, [Column6] = @Column6, [Column7] = @Column7, [Column8] = @Column8, [Column9] = @Column9, [Column10] = @Column10 WHERE [ID] = @ID">
            <DeleteParameters>
                <asp:Parameter Name="ID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="Column1" Type="String" />
                <asp:Parameter Name="Column2" Type="String" />
                <asp:Parameter Name="Column3" Type="String" />
                <asp:Parameter Name="Column4" Type="String" />
                <asp:Parameter Name="Column5" Type="String" />
                <asp:Parameter Name="Column6" Type="String" />
                <asp:Parameter Name="Column7" Type="String" />
                <asp:Parameter Name="Column8" Type="String" />
                <asp:Parameter Name="Column9" Type="String" />
                <asp:Parameter Name="Column10" Type="String" />
                <asp:Parameter Name="ID" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="ID" Type="Int32" />
                <asp:Parameter Name="Column1" Type="String" />
                <asp:Parameter Name="Column2" Type="String" />
                <asp:Parameter Name="Column3" Type="String" />
                <asp:Parameter Name="Column4" Type="String" />
                <asp:Parameter Name="Column5" Type="String" />
                <asp:Parameter Name="Column6" Type="String" />
                <asp:Parameter Name="Column7" Type="String" />
                <asp:Parameter Name="Column8" Type="String" />
                <asp:Parameter Name="Column9" Type="String" />
                <asp:Parameter Name="Column10" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>
    </div>
Vasil
Telerik team
 answered on 18 Sep 2012
1 answer
185 views
When you click the "Today" button in the fast navigation pane it only takes you to the current month.  I read a post from 3 years ago that mentioned this is the expected behavior.  Why is this still the behavior?  Why can't this automatically choose todays date also? You know like the button states?

I imagine 99.99% if not all of the user population would expect "Today" to choose todays date in the datepicker. 
Eyup
Telerik team
 answered on 18 Sep 2012
1 answer
67 views
hi ,
i have column group with header text(Actions) this header will apply on all grids ,
i want to add this to  GlobalResources  file ,how to add it?
Eyup
Telerik team
 answered on 18 Sep 2012
5 answers
116 views
Hi,

I have found a layout issue with using the spell check feature of the RadEditor, for some reason it is causing the height of the Editor to increase and overlap the content below.  This happens in IE7 and not in Firefox.

You can recreate this issue by going to your live examples in IE7 here and choosing the spell checker.  You can see that part of the content below ("Example Source Code & Description") is being overlapped by the RadEditor.

Is there a solution to resolve this?

Thanks for your help,

Jeff
Rumen
Telerik team
 answered on 18 Sep 2012
1 answer
89 views
In the attached code I copied directly from your code in demos to create a radio button from a RadButton.  I cannot get it to work.  Please tell me what I did wrong. 

Thanks.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="TestBed2.aspx.vb" Inherits="TestBed2" %>
 
<!DOCTYPE html>
 
<head runat="server">
    <title></title>
    <style type="text/css">
        .classDiv
        {
            float: left;
            width: 150px;
        }
        .clear
        {
            width: 100%;
            clear: both;
            height: 110px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server">
        </telerik:RadStyleSheetManager>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js">
                </asp:ScriptReference>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js">
                </asp:ScriptReference>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js">
                </asp:ScriptReference>
            </Scripts>
        </telerik:RadScriptManager>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        </telerik:RadAjaxManager>
    <div class="classDiv">
        <telerik:RadButton ID="RadButton16" runat="server" ToggleType="Radio" ButtonType="StandardButton"
            GroupName="StandardButton" AutoPostBack="false">
            <ToggleStates>
                <telerik:RadButtonToggleState Text="Checked" PrimaryIconCssClass="rbToggleRadioChecked" />
                <telerik:RadButtonToggleState Text="UnChecked" PrimaryIconCssClass="rbToggleRadio" />
            </ToggleStates>
        </telerik:RadButton>
        </div>
    </form>
</body>
</html>
Slav
Telerik team
 answered on 18 Sep 2012
3 answers
127 views
hello. telerik team.
i found a problem with focusing in radgrid at safari browser.

i'm using safari browser v5.1.5

i can't set focus to hyperlink column by pressing tab key
every browser works fine. but  except safari.

please refer below your grid demo.
http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/columntypes/defaultcs.aspx
Galin
Telerik team
 answered on 18 Sep 2012
4 answers
235 views
Hey everyone,

I have a grid,its data source is a data table.I've created columns in the data table.and at page_load grid is visible with no records in it & just names of the columns.Now,I've a button external to the grid which i am using to open up the insert Form.I've created form template for inserting values.It also have 2 buttons Save and Cancel.

Now,on Save button I put all the values inserted by the user in the first row of the data table.And it is visible in the data Table when i see using breakpoints.But My problem is that it remains in the Data Table and is not Visible in the Grid.I want Grid to show values inside the data Table and values keeps on increasing as user inserts more items to the Data Table.

My code for CS is--
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            dtValues = new DataTable();
            dtValues.Columns.Add("Items");
            dtValues.Columns.Add("Rate");
            dtValues.Columns.Add("Quantity");
            dtValues.Columns.Add("Amount");
            RadGrid1.DataSource = dtValues;
        }
protected void btnAdd_Click(object sender, EventArgs e)
        {
            RadGrid1.MasterTableView.IsItemInserted = true;
            RadGrid1.MasterTableView.Rebind();
        }
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridEditFormInsertItem && e.Item.OwnerTableView.IsItemInserted)
            {
                GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item;
                RadComboBox combo = insertItem.FindControl("RadComboBox1") as RadComboBox;
                combo.AutoPostBack = true;
                combo.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(combo_SelectedIndexChanged);
                Button Save = insertItem.FindControl("btnSave") as Button;
                Save.Click += new EventHandler(Save_Click);
                Button cancel = insertItem.FindControl("btnCancel") as Button;
                cancel.Click += new EventHandler(Cancel_Click);
            }
        }
protected void Cancel_Click(object sender, EventArgs e)
        {
            Button Cancel = (Button)sender;
            GridEditFormInsertItem insertItem = (GridEditFormInsertItem)Cancel.NamingContainer;
            RadComboBox combo = insertItem.FindControl("RadComboBox1") as RadComboBox;
            Label lblRate = (Label)insertItem.FindControl("lblRate");
            RadNumericTextBox txtQauntityE = (RadNumericTextBox)insertItem.FindControl("txtQuantityE");
            Label lblAmount = (Label)insertItem.FindControl("lblAmount");
            combo.SelectedIndex = -1;
            lblRate.Text = "";
            txtQauntityE.Text = "";
            lblAmount.Text = "";
            RadGrid1.MasterTableView.IsItemInserted = false;
            RadGrid1.MasterTableView.Rebind();
        }
 
        protected void Save_Click(object sender, EventArgs e)
        {
            Button Save = (Button)sender;
            GridEditFormInsertItem insertItem = (GridEditFormInsertItem)Save.NamingContainer;
            RadComboBox combo = insertItem.FindControl("RadComboBox1") as RadComboBox;
            Label lblRate = (Label)insertItem.FindControl("lblRate");
            RadNumericTextBox txtQauntityE = (RadNumericTextBox)insertItem.FindControl("txtQuantityE");
            Label lblAmount = (Label)insertItem.FindControl("lblAmount");
            if (combo.SelectedIndex > 0 && txtQauntityE.Text != null)
            {
                DataRow drValues = dtValues.NewRow();
                drValues["Items"] = combo.SelectedItem.Text;
                drValues["Rate"] = lblRate.Text;
                drValues["Quantity"] = txtQauntityE.Text;
                drValues["Amount"] = lblAmount.Text;
                dtValues.Rows.Add(drValues);
                dtValues.AcceptChanges();
                RadGrid1.DataSource = dtValues;
                RadGrid1.Rebind();
                RadGrid1.MasterTableView.IsItemInserted = false;
                RadGrid1.MasterTableView.Rebind();
            }
            else
            {
                 
            }
        }
protected void combo_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            RadComboBox combo = (RadComboBox)o;
            GridEditFormInsertItem insertItem = (GridEditFormInsertItem)combo.NamingContainer;
            Label lblRate = (Label)insertItem.FindControl("lblRate");
            SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["conn"].ToString());
            SqlCommand cmd = new SqlCommand("select [Rate] FROM [tblProducts] where ProductName=@ProductName", conn);
            cmd.Parameters.Add(new SqlParameter("@ProductName", combo.SelectedValue));
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            if (ds.Tables[0].Rows.Count > 0)
            {
                lblRate.Text = ds.Tables[0].Rows[0].ItemArray.GetValue(0).ToString();
            }
            RadNumericTextBox Quantity = (RadNumericTextBox)insertItem.FindControl("txtQuantityE");
            Quantity.Focus();
        }
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridEditFormInsertItem && e.Item.OwnerTableView.IsItemInserted)
            {
                GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item;
            }
        }
What's wrong with this,Am i missing something OR is this NOT POSSIBLE to insert temporary items to grid using data Table as Data Source.Plz help...

Thanks
Amit
Kostadin
Telerik team
 answered on 18 Sep 2012
3 answers
319 views
Hi,
I have a radgrid with an edit form template. There are multiple entry fields in the edit form.
I have a textbox in a radgrid that must be unique. I have created a custom validator for the insert so that it checks to make sure the value does not exist in the database and this works fine. However, if I use the same custom validator in the radgrid edit template, it will not let me update a row with the original value because it sees that it is already in the database. I use  page.isvalid to check before updating the radgrid. How do I get around this issue? Any help is appreciated! Thanks!
Radoslav
Telerik team
 answered on 18 Sep 2012
2 answers
133 views
I am having one heck of a time getting QTP to play fair with these Telerik controls.  The most recent issue, being able to Set a value in an edit.  I can set the value using extra code but for some reason, when a search is invoked, it ignores the entered value and performs an open search.  Here's the QTP code including all the code lines that won't work :(.
    'Enter Branch Office name for LookUp
      '''vSearchedit = "name:=ctl00\$c\$NameTextBox
    Browser(vBrowser).Page(vPage).WebEdit(vSearchEdit).Click
    Wait 1
    'Browser(vBrowser).Page(vPage).WebEdit(vSearchEdit).Set brNameIn
    'Browser(vBrowser).Page(vPage).WebEdit(vSearchEdit).Type brNameIn
    'Browser(vBrowser).Page(vPage).WebEdit(vSearchEdit).Object.Value = brNameIn
    'Browser(vBrowser).Page(vPage).WebEdit(vSearchEdit).Object.Click
 
'   ''''have to use this ReplayType technique gotta love telerik
Setting.WebPackage("ReplayType") = 2
    Browser(vBrowser).Page(vPage).WebEdit(vSearchEdit).set brNameIn
    Setting.WebPackage("ReplayType") = 1
 
    Wait 1
 
    Browser(vBrowser).Page(vPage).WebEdit(vSearchEdit).Click
 
    Wait 1
 
    didSet = Browser(vBrowser).Page(vPage).WebEdit(vSearchEdit).GetROProperty("value")
    If didSet <> "" Then
        Wait 1
        'Press the Search button
        Browser(vBrowser).Page(vPage).WebButton("name:=Search").Click
    Else
        Reporter.ReportEvent micFail, "Set Entity Search", "Unable to set the search value.  Check your code!!!!"
        ExitTestIteration  
    End If

Why in the world would QTP be able to see a value in the edit, but the value is ignored when the search is invoked?  It's not a problem with the search itself as it works if I manually enter my filter into the edit.  I am also including the source from the edit in question in case that might help...
<span class="riSingle RadInput RadInput_Office2007" id="ctl00_c_NameTextBox_wrapper" style="width: 180px;"><input name="ctl00$c$NameTextBox" tabIndex="2" class="riTextBox riEnabled" id="ctl00_c_NameTextBox" style="width: 165px;" type="text" size="20" _events="[object Object]" control="[object Object]" RadInputValidationValue="" /><input name="ctl00_c_NameTextBox_ClientState" id="ctl00_c_NameTextBox_ClientState" type="hidden" autocomplete="off" value='{"enabled":true,"emptyMessage":"","validationText":"","valueAsString":""}' /></span>


Thanks in advance,

Cathy
Vasil
Telerik team
 answered on 18 Sep 2012
1 answer
72 views
Im building a web app using the MVC archirecture (MVC3).  Is it somehow possible to use the RadScheduler in an mvc applcation ?
If so, are there any examples ?
Plamen
Telerik team
 answered on 18 Sep 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?