Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
77 views
Hi,

We have a Telerik Grid and also a list box. When I select a value from the multiple value list box drop down, I'm getting the following error

​Unhandled exception at line 15, column 16485
in http://localhost:37039/CrossEntitiesReport UAT Backup_Modify_28_4/
Telerik.Web.UI.WebResource.axd?_
TSM_HiddenField_=RadScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=;
;System.Web.Extensions,+Version=4.0.0.0,+Culture=neutral,
+PublicKeyToken=31bf3856ad364e35:en-US:5924cf72-83cf-477d-98eb-a608a92942c5:ea597d4b:b25378d2
;Telerik.Web.UI,+Version=2012.2.912.35,+Culture=neutral,+
PublicKeyToken=121fae78165ba3d4:en-US:9957980a-8113-4265-a8ae


Please let me know the solution for this

Thanks in advance
Nencho
Telerik team
 answered on 05 May 2014
6 answers
381 views
Can you have a Combobox inside:

<EditFormSettings EditFormType="Template">
                    <FormTemplate>
??? combo bound to datafield from grid????
      </FormTemplate>
</EditFormSettings>
Princy
Top achievements
Rank 2
 answered on 05 May 2014
5 answers
178 views
I have this block of code which worked at the prior version (VS 2010, older RadGrid control).  Now I upgraded to VS 2013 and use RadGrid control in version 2013.3.114.45,  I can't figure out why I can't get the "ApplicationId" value from e.item.

Please see code below:
private void LoadData()
        {
            if (RadGrid1.Items.Count > 0) RadGrid1.DataSource = new Object[0];            //If Academic year is selected
            if (editAcademicYear.SelectedValue !="Select One")
            {
                var academicyear = (from ay in context.AcademicYears
                                    where ay.Name == editAcademicYear.SelectedValue
                                    select ay).First();
                yearID = academicyear.AcademicYearID;
            }   if (rbLName.Checked)
   {
    if (editSName.Text.Length > 0)
    {
     if (yearID > 0)
     {
      application = from s in context.Applications.Include("AcademicYear")
           where s.LastName.StartsWith(editSName.Text.Trim()) &&
           s.AcademicYear.AcademicYearID == yearID
           orderby s.LastName, s.FirstName
           select s;
     }
     else
     {
      application = from s in context.Applications
           where s.LastName.StartsWith(editSName.Text.Trim())
           orderby s.LastName, s.FirstName
           select s;
     }
     ShowApps(application, application.Count());   //Show data to RadGrid1 for selection.    }
    else
    {
     lblmissing.Visible = true;
     lblmissing.Text = "Please enter the last name.";
     return;
    }
   }
         }
  
//question:  how can I get the value for dataItem below?  What is wrong here?
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
           
            LoadData();
            //from debugging, I saw "application" value, but I did not see value
              from RadGrid1 or its "items".            try
            {
                if (e.Item.ItemIndex > -1)
                {
                    var dataItem = e.Item as GridDataItem;   //dataItem has no value here
                    string appid = dataItem["ApplicationId"].Text;    //therefore, appid has no value
                    Response.Redirect("DisplayApp.aspx?appid=" + appid);
                }
            }
            catch (Exception ex)
            {
                logger.ErrorException("Could not get appid from the grid row", ex);
                lblMessage.Visible = true;
                RadGrid1.Visible = false;
                lblMessage.Text = "<b>Error exists in the grid level.  Please contact the Care Tech Support.</b>";
            }
    } 

I have spent a few hours searching, the site is in production, but just can't get the "appid" of the selected row to display the detail page.  Your quick response is much appreciated.

Thanks in advance!
Anieda
Top achievements
Rank 1
 answered on 05 May 2014
1 answer
85 views
Hi All:

I was working with underscore and figured out that I could reformat the data for the PanelBar control.
Here is my example code:
//
$(function () {
    //
    var meetingDataSource = new kendo.data.DataSource({
        data: [
            { MeetingId: 65, Year: 2014, MeetingDate: '2014-05-14 18:00:00', Title: "30 tools for modern .net web development in 60 minutes" },
            { MeetingId: 64, Year: 2014, MeetingDate: '2014-04-09 18:00:00', Title: "azure websites deep dive" },
            { MeetingId: 63, Year: 2014, MeetingDate: '2014-03-12 18:00:00', Title: "cancelled" },
            { MeetingId: 62, Year: 2014, MeetingDate: '2014-02-12 18:00:00', Title: "getting to know windows azure mobile services" },
            { MeetingId: 60, Year: 2013, MeetingDate: '2013-12-11 18:00:00', Title: "custom graphics for your web application: the html5 canvas and kinetic.js" },
            { MeetingId: 59, Year: 2013, MeetingDate: '2013-11-13 18:00:00', Title: "four platforms. one codebase. xamarin." },
            { MeetingId: 58, Year: 2013, MeetingDate: '2013-10-09 18:00:00', Title: "it’s cheaper than therapy: building an “eliza” psychotherapist app in windows 8" },
            { MeetingId: 57, Year: 2013, MeetingDate: '2013-09-11 18:00:00', Title: "if typescript is the answer, what is the question?" }
        ]
    });
    //
    meetingDataSource.fetch(function () {
        //
        var meetings = meetingDataSource.data();
        //
        var years = _.chain(meetings)
            .pluck('Year')
            .uniq()
            .value();
        //
        var shapedData = _.reduce(years, function (memo, year) {
            var exp = false;
            if (memo.length == 0) exp = true;
            //
            var det = _.chain(meetings)
                .filter(function (meeting) { return meeting.Year == year; })
                .map(function (meeting) {
                    var m = meeting;
                    return { value: m.MeetingId, text: m.Title };
                })
                .value();
            memo.push({ value: year, text: year, expanded: exp, items: det });
            return memo;
        }, []);
        //
        $("#inline-listview").kendoPanelBar({
            dataSource: shapedData,
            expandMode: "single"
        }).data("kendoPanelBar");
    });
    //
});

I read the data with a dataSource fetch command.  In the fetch function, I first extract the years for the level 0 of the panel-bar, then I use the years as input for the reduce function and reprocess the input data.  The years are the level 0 and the level 1 is the reprocessed data.

Phil
Phil
Top achievements
Rank 2
 answered on 04 May 2014
6 answers
135 views
I have copied as it is this demo but I am unable to insert/update the records.
private static DataTable GetDataTable(string queryString)
      {
          String connString = ConfigurationManager.ConnectionStrings["NORTHWNDConnectionString"].ConnectionString;
           SqlConnection mySqlConnection = new SqlConnection(connString);
           SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter();
           mySqlDataAdapter.SelectCommand = new SqlCommand(queryString, mySqlConnection);
 
           DataTable myDataTable = new DataTable();
           mySqlConnection.Open();
           try
           {
                mySqlDataAdapter.Fill(myDataTable);
           }
           finally
           {
                mySqlConnection.Close();
           }
 
           return myDataTable;
      }
 
      private DataTable Employees
      {
           get
           {
                object obj = this.Session["Employees"];
                if ((!(obj == null)))
                {
                     return ((DataTable)(obj));
                }
                DataTable myDataTable = new DataTable();
                myDataTable = GetDataTable("SELECT * FROM Employees");
                this.Session["Employees"] = myDataTable;
                return myDataTable;
           }
      }
 
      protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
      {
           this.RadGrid1.DataSource = this.Employees;
           this.Employees.PrimaryKey = new DataColumn[] { this.Employees.Columns["EmployeeID"] };
      }
 
      protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)
      {
           GridEditableItem editedItem = e.Item as GridEditableItem;
           UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
 
           //Prepare new row to add it in the DataSource
           DataRow[] changedRows = this.Employees.Select("EmployeeID = " + editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["EmployeeID"]);
 
           if (changedRows.Length != 1)
           {
                RadGrid1.Controls.Add(new LiteralControl("Unable to locate the Employee for updating."));
                e.Canceled = true;
                return;
           }
 
           //Update new values
           Hashtable newValues = new Hashtable();
 
           newValues["Country"] = (userControl.FindControl("TextBox7") as TextBox).Text;
           newValues["City"] = (userControl.FindControl("TextBox8") as TextBox).Text;
           newValues["Region"] = (userControl.FindControl("TextBox9") as TextBox).Text;
           newValues["HomePhone"] = (userControl.FindControl("HomePhoneBox") as RadMaskedTextBox).Text;
           newValues["BirthDate"] = (userControl.FindControl("BirthDatePicker") as RadDatePicker).SelectedDate.ToString();
           newValues["TitleOfCourtesy"] = (userControl.FindControl("ddlTOC") as DropDownList).SelectedItem.Value;
 
           newValues["Notes"] = (userControl.FindControl("TextBox1") as TextBox).Text;
           newValues["Address"] = (userControl.FindControl("TextBox6") as TextBox).Text;
           newValues["FirstName"] = (userControl.FindControl("TextBox2") as TextBox).Text;
           newValues["LastName"] = (userControl.FindControl("TextBox3") as TextBox).Text;
           newValues["HireDate"] = (userControl.FindControl("HireDatePicker") as RadDatePicker).SelectedDate.ToString();
           newValues["Title"] = (userControl.FindControl("TextBox4") as TextBox).Text;
 
           changedRows[0].BeginEdit();
           try
           {
                foreach (DictionaryEntry entry in newValues)
                {
                     changedRows[0][(string)entry.Key] = entry.Value;
                }
                changedRows[0].EndEdit();
                this.Employees.AcceptChanges();
           }
           catch (Exception ex)
           {
                changedRows[0].CancelEdit();
 
                Label lblError = new Label();
                lblError.Text = "Unable to update Employees. Reason: " + ex.Message;
                lblError.ForeColor = System.Drawing.Color.Red;
                RadGrid1.Controls.Add(lblError);
 
                e.Canceled = true;
           }
      }
 
      protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e)
      {
           UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
 
           //Create new row in the DataSource
           DataRow newRow = this.Employees.NewRow();
 
           //Insert new values
           Hashtable newValues = new Hashtable();
 
           newValues["Country"] = (userControl.FindControl("TextBox7") as TextBox).Text;
           newValues["City"] = (userControl.FindControl("TextBox8") as TextBox).Text;
           newValues["Region"] = (userControl.FindControl("TextBox9") as TextBox).Text;
           newValues["HomePhone"] = (userControl.FindControl("HomePhoneBox") as RadMaskedTextBox).Text;
           newValues["BirthDate"] = (userControl.FindControl("BirthDatePicker") as RadDatePicker).SelectedDate.ToString();
           newValues["TitleOfCourtesy"] = (userControl.FindControl("ddlTOC") as DropDownList).SelectedItem.Value;
 
           newValues["Notes"] = (userControl.FindControl("TextBox1") as TextBox).Text;
           newValues["Address"] = (userControl.FindControl("TextBox6") as TextBox).Text;
           newValues["FirstName"] = (userControl.FindControl("TextBox2") as TextBox).Text;
           newValues["LastName"] = (userControl.FindControl("TextBox3") as TextBox).Text;
           newValues["HireDate"] = (userControl.FindControl("HireDatePicker") as RadDatePicker).SelectedDate.ToString();
           newValues["Title"] = (userControl.FindControl("TextBox4") as TextBox).Text;
 
           //make sure that unique primary key value is generated for the inserted row
           newValues["EmployeeID"] = (int)this.Employees.Rows[this.Employees.Rows.Count - 1]["EmployeeID"] + 1;
           try
           {
                foreach (DictionaryEntry entry in newValues)
                {
                     newRow[(string)entry.Key] = entry.Value;
                }
                this.Employees.Rows.Add(newRow);
                this.Employees.AcceptChanges();
           }
           catch (Exception ex)
           {
                Label lblError = new Label();
                lblError.Text = "Unable to insert Employees. Reason: " + ex.Message;
                lblError.ForeColor = System.Drawing.Color.Red;
                RadGrid1.Controls.Add(lblError);
 
                e.Canceled = true;
           }
      }
      protected void RadGrid1_DeleteCommand(object source, GridCommandEventArgs e)
      {
           string iD = (e.Item as GridDataItem).OwnerTableView.DataKeyValues[e.Item.ItemIndex]["EmployeeID"].ToString();
           DataTable employeeTable = this.Employees;
           if (employeeTable.Rows.Find(iD) != null)
           {
                employeeTable.Rows.Find(iD).Delete();
                employeeTable.AcceptChanges();
           }
      }

Is there anything that needs tobe changed? Could you please point me to the right direction?
Thanks,
Felice
Felice
Top achievements
Rank 1
 answered on 04 May 2014
4 answers
178 views
I have a page where the user can add new RadTextTiles to a RadTileList dynamically.  This is handled on the server-side by creating a new RadTextTile in memory and adding it like this:

RadTileList1.GetAllTiles.Add(newTile)

On postback these items do not survive - which is becoming problematic.  Is there a setting or something I am missing that will force RadTextTiles created dynamically on the server (not from databind) to survive a postback?  Other Telerik controls that we use do not display this behavior, so not sure if we are doing something wrong here?

The reason this is a problem is because we are also trying to implement the Persistence Framework, to track the Tile sort order the user sets.  Problem is that the Tiles that are added via the .Add command, are not there on postback, so we cannot pickup their position.
Dan
Top achievements
Rank 1
 answered on 04 May 2014
7 answers
126 views
Hallo I saw the example at
http://demos.telerik.com/aspnet-ajax/fileexplorer/examples/applicationscenarios/customgridcolumns/defaultvb.aspx?#qsf-demo-source
And I also read some other topics and stuff in the control reference but still I didn't come up with an idea on how to solve this.
I use the explorer to upload images (for news, profiles, whatever) and I need to make one of all the uploaded images as the "main one".
I handled all the logic for this but now I would like to display a little image in the file explorer grid near the "main image" so that users can see at a glance which one is the "main image".
So I need to add a column to the grid which will show that image only if the filename is equal to the "main image file name, which I keep in my page/usercontrol property (hidden input field or whatever).
So mangling with the file provider is not useful in my situation since I have to match the file name with a variable which is not accessible inside the file provider (I guess).

Any hint?

Thanks in advance
Massimiliano
Top achievements
Rank 1
 answered on 03 May 2014
2 answers
179 views
I was creating a Kendo grid that contains several column.  There is one numeric column called 'Length".  When I clicked on this column, I would expect it to invoke the editor, but unfortunately it crashed in kendo.all.js.  I have no idea what I did wrong.  I am hoping someone here could take a look at it and give me some advice on how to fix my code.

Here is a sample of my code:
http://jsbin.com/wikav/1/edit


Thanks in advance.





Chuen
Top achievements
Rank 1
 answered on 03 May 2014
2 answers
121 views
Hi,

I'd like to know if the Ribbonbar has any support for using sprites instead of images directly?  And if not if there were any plans to add support in a future release.

Thanks!
Richard
Richard
Top achievements
Rank 1
 answered on 02 May 2014
1 answer
75 views
Hi everybody,
i want to populate a ComboBox that exist on the EditFormTemplate of a detailTable base on the ParentItem DataKeyValue, when the user click on the btn add new record, so here's my code :

public void radGrid_ItemCommand(object sender, GridCommandEventArgs e)
        {
            if (e.CommandName == RadGrid.InitInsertCommandName)
            {
                if (e.Item.OwnerTableView.Name == "ChildGrid")
                {
                    GridDataItem parentItem = (GridDataItem)(e.Item.OwnerTableView.ParentItem);
                   
                    if (parentItem != null)
                    {
                        int itemId= Convert.ToInt32(parentItem.OwnerTableView.DataKeyValues[parentItem.ItemIndex]["Id"]);
                        //i want to get here the ComboBox control and the code (as i think) should look like this :
                        RadComboBox = e.item.findControl("comboId") as RadComboBox;
                    }

                }
                
            }
        }

thanks.
Said
Top achievements
Rank 1
 answered on 02 May 2014
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?