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..
| <telerik:RadComboBox ID="uxContact" Runat="server" EmptyMessage=" - Select a Client - " AllowCustomText="true" CssClass="fullWidthComboBoxSP" onclientselectedindexchanging="LoadContactChildren" onitemsrequested="uxContact_ItemsRequested" OnClientItemsRequested="DropDownLoaded" MarkFirstMatch="True"></telerik:RadComboBox> |
| JS |
| uxContact = $find('uxFormView_uxContact'); |
| alert(uxContact.get_value()); |
| VB.NET |
| DirectCast(uxFormView.FindControl("uxContact"), RadComboBox).SelectedValue |
protected void RadGridAssetExtrasCondition_ItemDataBound(object sender, GridItemEventArgs e) { switch (e.Item.OwnerTableView.Name) { case "AssetExtrasCondition": if (e.Item is GridCommandItem) { Do some stuff here } if (e.Item is GridDataItem) { Do some stuff here } if ((e.Item is GridEditFormItem || e.Item is GridEditFormInsertItem) && e.Item.IsInEditMode) { var ctrlLabelConditionRatingDescription = (Label)e.Item.FindControl("LabelConditionRatingDescription"); var ctrlRadRatingCondition = (RadRating)e.Item.FindControl("RadRatingCondition"); // Creating the Rad Rating stars dynamically foreach (var item in this.ConditionRatings.Items) { var ratingItem = new RadRatingItem { Value = Convert.ToDecimal(item.Rating), ToolTip = item.Rating.ToString() }; ctrlRadRatingCondition.Items.Add(ratingItem); } ctrlRadRatingCondition.Attributes.Add("onclientrated", "alert('hello');"); if (!e.Item.OwnerTableView.IsItemInserted) { Do some stuff here } } break; } }protected void Page_Init() { ConfigureGrid(); } private void ConfigureGrid() { OrderTypeRankingGrid.AddNeedDataSourceEventHandler(NeedDataSource); // Binding master table view OrderTypeRankingGrid.AddGridCommandEventHandler(DataGrid_ItemCommand); // Events for the standard ngm controls OrderTypeRankingGrid.AllowColumnsReorder = false; OrderTypeRankingGrid.GridHeaderText = "Order Type Ranking"; var masterView = OrderTypeRankingGrid.ConfigureMasterTableView("vDivisionOrderTypeRanking", new string[] { "DivisionOrderTypeRankId" }); masterView.AllowFilteringByColumn = true; masterView.AllowSorting = true; masterView.FullEditMode = true; masterView.EditMode = GridEditMode.InPlace; masterView.EnableShowHideColumns = true; masterView.SetPaging(GridPagerMode.NextPrevAndNumeric); masterView.GridTableView.ShowHeader = true; masterView.ShowHeader = true; masterView.ShowFooter = true; masterView.ShowHeadersWhenNoRecords = true; masterView.AllowPaging = true; //Enable standard Ngm controls masterView.AddNgmCommandButton(NgmButtonType.Save, "btnSave", null, null, "Save Function Id", Unit.Pixel(50)); masterView.AddNgmCommandButton(NgmButtonType.Cancel, null, null, null, null, Unit.Pixel(50)); masterView.CommandItemDisplay = GridCommandItemDisplay.Bottom; if (!IsPostBack) //must check for postback; otherwise, columns will be duplicated { //masterView.AddBoundColumn("DivisionOrderTypeRankId", "Rank ID", null, true, false, true, Unit.Percentage(7.0)); masterView.AddBoundColumn("CategoryCode", "Category Code", null, true, false, true, Unit.Percentage(7.0)); masterView.AddBoundColumn("PurposeCode", "Purpose Code", null, true, false, true, Unit.Percentage(7.0)); masterView.AddBoundColumn("ReasonCode", "Reason Code", null, true, false, true, Unit.Percentage(7.0)); masterView.AddBoundColumn("ReasonDescription", "Reason Description", null, true, false, true, Unit.Percentage(7.0)); masterView.AddBoundColumn("OrderTypeRank", "Rank", null, false, false, true, Unit.Percentage(7.0)); } } protected void NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) { if (IsPostBack) { if (!e.IsFromDetailTable && (this.productDivision == 1 || this.productDivision == 2)) { IDivisionOrderTypeRankService divisionOrderTypeRankServiceAgent = null; divisionOrderTypeRankServiceAgent = (IDivisionOrderTypeRankService)ContextRegistry.GetContext().GetObject("DivisionOrderTypeRankServiceAgent"); IList<DivisionOrderTypeRankDTO> divisionOrderTypeRankDTOs = divisionOrderTypeRankServiceAgent.GetDivisionOrderTypeRankByDivision(productDivision); OrderTypeRankingGrid.DataSource = divisionOrderTypeRankDTOs; } } }