I am new to the telerik tools, and I am using the RadGrid control. Basically I have the grid populated with data, and I have a
GridEditCommandColumn
. When I click the edit button it turns any fields that aren't set to ReadOnly into editable controls (edit in place). Two of the columns are GridDateTimeColumn(s) that when in edit mode show as what appears to look similar to a TextBox with a Date and Time Picker next to the "TextBox."
I can't for the life of me, when I select a different date or time, access the new value via c# codebehind when I click update. Hopefully my code will help explain what I am trying to do. This code appears in my RadGrid1_UpdateCommand
-- This works and updates my Sql database table. Basically it recognizes the text fields inside the TextBox without any problems.
TableCell cell8 = item["RunDuration"]; --"RunDuration" is my UniqueName for that GridBoundColumn
string _RunDuration = (cell8.Controls[0] as TextBox).Text;
myClass.RunDuration = Convert.ToDecimal(_RunDuration); -- I created a class in c# to handle inserts/updates
-- I can't get this to work, and I am not sure how to reference a cell that has a Datetimepicker... it doesn't appear to be a textbox, but I
-- can't figure out how to reference it.
TableCell cell6 = item["RunStartTime"];
RadDatePicker _StartTime = (cell6.Controls[0] as RadDatePicker);
mfgProductionRun.StartTime = Convert.ToDateTime(_StartTime);
I get an error of: Unable to cast object of type 'Telerik.Web.UI.RadDateTimePicker' to type 'System.IConvertible'.
Any help is greatly appreciated. I just want to be able to click the edit button, change the datetime fields if necessary and then have the new values write to the Sql database when I click update..