/// <summary> /// Handles the OnItemDataBound event of the rgPublicationComment control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Telerik.Web.UI.GridItemEventArgs"/> instance containing the event data.</param> protected void rgPublicationComment_OnItemDataBound(object sender, GridItemEventArgs e) { if ((e.Item is GridEditFormItem) && e.Item.IsInEditMode) { var gridEditFormItem = (GridEditFormItem)e.Item; var item = e.Item as GridEditableItem; ContactComboBox ucUser = (ContactComboBox)item.FindControl("ucUser"); ucUser.FilterByFullName = true; ucUser.ValidationGroup = "valRelatedPublicationCommentGroup"; ((RadDatePicker)item.FindControl("rdpDate")).SelectedDate = DateTime.Now; if (!(gridEditFormItem.DataItem is GridInsertionObject)) { var publicationComment = (PublicationCommentStructure)gridEditFormItem.DataItem; if (publicationComment != null) { ucUser.SelectedValue = publicationComment.UserID; ((TextBox)item.FindControl("txtComment")).Text = publicationComment.Comment; ((RadDatePicker)item.FindControl("rdpDate")).SelectedDate = publicationComment.Date; ((CheckBox)item.FindControl("cbOfficial")).Checked = publicationComment.isOfficialAnswer; } } } }
protected void rgPublicationMarks_DataBound(object sender, GridItemEventArgs e) { //if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem) //{ // Control target = e.Item.FindControl("targetControl"); // if (!Object.Equals(target, null)) // { // if (!Object.Equals(this.RadToolTipManager1, null)) // { // //Add the button (target) id to the tooltip manager // this.RadToolTipManager1.TargetControls.Add(target.ClientID, // (e.Item as GridDataItem).GetDataKeyValue("PublicationCommentID").ToString(), true); // } // } //} if (e.Item is GridEditFormItem && e.Item.IsInEditMode) { var item = e.Item as GridEditableItem; ContactComboBox ucUser = (ContactComboBox)item.FindControl("ucUser"); ucUser.FilterByFullName = true; ucUser.ValidationGroup = "valPublicationMarkGroup"; var ddlType = (DropDownList)item.FindControl("ddlType"); ddlType.Items.Clear(); foreach (var publicationMarkType in EnumHelper.EnumToList <PublicationMarkType>()) { ddlType.Items.Add(new ListItem(EnumHelper.GetEnumDescription(publicationMarkType), ((int)publicationMarkType).ToString())); } var ddlComment = (DropDownList)item.FindControl("ddlComment"); ddlComment.DataSource = dataManager.PublicationComment.SelectByPublicationId(PublicationID); ddlComment.DataValueField = "ID"; ddlComment.DataTextField = "CreatedAt"; ddlComment.Items.Add(new ListItem() { Text = "Выберите значение", Value = Guid.Empty.ToString(), Selected = true }); ddlComment.DataBind(); ((RadDatePicker)item.FindControl("rdpDate")).SelectedDate = DateTime.Now; if (!e.Item.OwnerTableView.IsItemInserted) { var publicationMarks = (PublicationMarkStructure)item.DataItem; ((RadDatePicker)item.FindControl("rdpDate")).SelectedDate = publicationMarks.CreatedAt; ((RadNumericTextBox)item.FindControl("rtbRank")).Value = publicationMarks.Rank; ddlType.SelectedIndex = ddlType.Items.IndexOf(ddlType.Items.FindByValue(publicationMarks.TypeID.ToString())); ddlComment.SelectedIndex = ddlComment.Items.IndexOf(ddlComment.Items.FindByValue(publicationMarks.PublicationCommentID.ToString())); ucUser.SelectedValue = publicationMarks.UserID; } } }