Telerik check blank row exist

2 posts, 0 answers
  1. Raju Guratafi
    Raju Guratafi avatar
    3 posts
    Member since:
    Oct 2012

    Posted 22 Jan 2013 Link to this post

    I am currently create an web application to load the selected order in the client transaction record by clicking the copy button in the RadGrid. I implement this by getting the id of the order and retrieve the required entity to insert the form.

    JS Runtime Error That Microsoft JScript runtime error: 'document.getElementById(...)' is null or not an object By using MVVM Model , I preset the blank row to be null in terms of the mapped fields such as consumer ID , order ID , consumer Name , Price and so on .

    The Order Reference Id is named as referenceOrder and retrieve the LoadReference to insert the record

    I am currently using C# , Visual Studio 2012.

    What I want to ask is there any methodology to check if the row is blank before the copy action being executed ?

    The below is my code



     protected void grdCustomerReport_ItemCommand(object sender, GridCommandEventArgs e)
        {
            // [Start] Declare Grid and GridData.
            RadGrid CurrentGrid = (RadGrid)sender;
            GridDataCustomerReport GridSource = PageSource.GrdCustomerReport;
            //[End] 
            if (e.CommandName == "CustomInsert" &&
                GridSource.state != GridModelState.Edit)
            {
               //Add blank row
            }
            else if (e.CommandName == "DeleteCurrent")
            {
              //Delete Row
                CurrentGrid.Rebind();
            }
            else if (e.CommandName == "Copy") <--I click the button and retrieve the dataset index 
            {
                //Check if there is empty row  ? 
    
                int referenceOrder ;
                int rowIndex = Convert.ToInt32(e.CommandArgument);
    
                RadComboBox cbo= (RadComboBox) CurrentGrid.Items[rowIndex].FindControl("cboCode");
                if (cbo.SelectedIndex > 0  && cbo.SelectedValue != "")
                {
                    referenceOrder = Convert.ToInt32(cbo.SelectedValue);
                    PageSource.SetOrder(referenceOrder );
                    LoadReference();
                }
                else
                {
                   winAlert.RadAlert("<b>" + "Please Select Reference Orderin the Dropdown List" + "</b>.<br />", 330, 100, "", null);
                }
            }
        }
  2. Angel Petrov
    Admin
    Angel Petrov avatar
    1006 posts

    Posted 25 Jan 2013 Link to this post

    Hi Raju,

    I am experiencing difficulties understanding your scenario. Could you please elaborate on who is firing the copy command. Isn't this being fired from a button in a grid row? If that is the case the grid item can not be blank and probably the CommandArgument is not passed correctly. I suggest that you modify the code like shown below:
    else if (e.CommandName == "Copy") <--I click the button and retrieve the dataset index
            {
                //Check if there is empty row  ?
     
                int referenceOrder ;
                GridDataItem item = e.Item as GridDataItem;
     
                RadComboBox cbo= (RadComboBox) item.FindControl("cboCode");
                if (cbo.SelectedIndex > 0  && cbo.SelectedValue != "")
                {
                    referenceOrder = Convert.ToInt32(cbo.SelectedValue);
                    PageSource.SetOrder(referenceOrder );
                    LoadReference();
                }
                else
                {
                   winAlert.RadAlert("<b>" + "Please Select Reference Orderin the Dropdown List" + "</b>.<br />", 330, 100, "", null);
                }
            }
    Could you please show us your markup with the relevant code-behind so we could get a better view over your setup? Also please elaborate more about the JavaScript error as I do not see a relation between the server-side code and JavaScript error.

    Regards,
    Angel Petrov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top