Telerik Forums
UI for ASP.NET AJAX Forum
6 answers
529 views
Hi There,

I was trying to find CheckBox in the form using below code. When user clicks on the "SAVE" button, if user does not check checkbox in the form, it should ask user to select the "CheckBox" using Message box(Yes\No). If user selects "Yes" then it should automatically check the CheckBox. Please help. 

ASPX file

<%@ Page Title="" Language="C#" MasterPageFile="~/DefaultMaster.master" AutoEventWireup="true" CodeFile="ContentDetail.aspx.cs" Inherits="ContentDetailPage" %>
<%@ MasterType VirtualPath="~/DefaultMaster.master" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script type="text/javascript">
function CheckBeforeDelete(sender, args) {
args.set_cancel(!window.confirm("Are you sure you would like to delete this record?"));
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Skin="Default" runat="server"
MinDisplayTime="1000" InitialDelayTime="0">
</telerik:RadAjaxLoadingPanel>

<telerik:RadWindowManager ID="RadWindowManager1" runat="server" />

<telerik:RadWindow ID="confirmWindow" runat="server" VisibleTitlebar="true" VisibleStatusbar="false"
Modal="true" Behaviors="None" Height="150px" Width="300px">
<ContentTemplate>
<div style="padding-left: 30px; padding-top: 20px; width: 200px; float: left;">
<asp:Label ID="lblConfirm" Font-Size="14px" Text="Is this the Content change?" runat="server"></asp:Label>
<br />
<br />
<telerik:RadButton ID="RadButtonYes" runat="server" Text="Yes" AutoPostBack="false"
OnClientClicked="confirmResult" >
</telerik:RadButton>

<telerik:RadButton ID="RadButtonNo" runat="server" Text="No" AutoPostBack="false"
OnClientClicked="confirmResult">
</telerik:RadButton>
</div>
</ContentTemplate>
</telerik:RadWindow>

<asp:FormView ID="FormView1" runat="server" DataKeyNames="ContentId" DefaultMode="Edit"
DataSourceID="DocumentContentDataSource" ondatabound="FormView1_DataBound"
onitemdeleted="FormView1_ItemDeleted" onprerender="FormView1_PreRender"
>
<EditItemTemplate>
<asp:HiddenField ID="HiddenField1" runat="server" Value='<%# Bind("VersionId") %>' />
<asp:HiddenField ID="HiddenField3" runat="server" Value='<%# Bind("ParentContentId") %>' />
<asp:HiddenField ID="HiddenField5" runat="server" Value='<%# Bind("Level") %>' />
<asp:HiddenField ID="HiddenField6" runat="server" Value='<%# Bind("CreatedBy") %>' />
<asp:HiddenField ID="HiddenField2" runat="server" Value='<%# Bind("CreatedDate") %>' />
<asp:HiddenField ID="HiddenField8" runat="server" Value='<%# Bind("LastUpdatedBy") %>' />
<asp:HiddenField ID="HiddenField7" runat="server" Value='<%# Bind("LastUpdatedDate") %>' />
<asp:HiddenField ID="HiddenField4" runat="server" Value='<%# Bind("SortNo") %>' />
<asp:HiddenField ID="HiddenField9" runat="server" Value='<%# Bind("HierarchySortNo") %>' />
<table>
<tr style="height:30px">
<td>
<span class="label">Context:&nbsp;</span>
</td>
<td>
<asp:Label ID="LabelParent" CssClass="label" runat="server" />
</td>
</tr>
<tr>
<td>
<span class="label">Section Type:</span>
</td>
<td>
<asp:Label ID="LabelSectionType" CssClass="label" Text='<%# Eval("SectionType") %>' runat="server" />
</td>
</tr>
<tr>
<td>
<span class="label">Section Name:&nbsp;</span>
</td>
<td>
<telerik:RadTextBox ID="RadTextBoxContentName" Width="450px" Runat="server"
Text='<%# Bind("ContentName") %>'>
</telerik:RadTextBox>&nbsp;&nbsp;
<telerik:RadButton ID="RadButtonIsMandatory" runat="server" Text="Mandatory" ToggleType="CheckBox"
ButtonType="ToggleButton" Checked='<%# Bind("IsMandatory") %>' Width="60px">
</telerik:RadButton>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" Display="Dynamic"
ControlToValidate="RadTextBoxContentName" ErrorMessage="Enter a section name"
CssClass="validate-warning">
</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<span class="label">Section Title:&nbsp;</span>
</td>
<td>
<telerik:RadTextBox ID="RadTextBoxContentLabel" Width="450px" Runat="server"
Text='<%# Bind("ContentLabel") %>'>
</telerik:RadTextBox>&nbsp;&nbsp;
<telerik:RadButton ID="RadButtonContentChanged" runat="server" Text="Content Change?" ToggleType="CheckBox"
ButtonType="ToggleButton" Checked='<%# Bind("ContentChangedInd") %>' Width="95px">
</telerik:RadButton>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" Display="Dynamic"
ControlToValidate="RadTextBoxContentLabel" ErrorMessage="Enter a section title"
CssClass="validate-warning">
</asp:RequiredFieldValidator>

</td>
</tr>
</table>
<table style="margin-top:10px">
</table>
<table style="margin-top:10px">
<tr>
<td>
<span class="label">Created:&nbsp;</span>
</td>
<td>
<asp:Label ID="Label1" CssClass="label" runat="server"
Text='<%# Eval("CreatedByUser.DisplayName") + " On " + Eval("CreatedDate") %>' />
</td>
<td style="padding-left:30px">
<span class="label">Last Updated:&nbsp;</span>
</td>
<td>
<asp:Label ID="Label2" CssClass="label" runat="server"
Text='<%# Eval("LastUpdatedByUser.DisplayName") + " On " + Eval("LastUpdatedDate") %>' />
</td>
</tr>
</table>
<div style="margin-top:10px">
<table>
<tr>
<td>
<telerik:RadEditor ID="RadEditor1" runat="server" Content='<%# Bind("Content") %>'
StripFormattingOptions="MsWord,Span,Css,ConvertWordLists" Width="625px" ToolsFile="~/RadEditorToolsFile.xml" ImageManager-ViewPaths="~/UserImages">
<CssFiles>
<telerik:EditorCssFile Value="~/Styles/radeditor.css" />
</CssFiles>
<Tools>
<telerik:EditorToolGroup>
<telerik:EditorTool Name="InsertDocumentLink" Text="Insert Within Document Link" />
</telerik:EditorToolGroup>
</Tools>
</telerik:RadEditor>
<script type="text/javascript">
Telerik.Web.UI.Editor.CommandList["InsertDocumentLink"] = function (commandName, editor, args) {

var myCallbackFunction = function (sender, args) {
editor.pasteHtml(String.format("<a href=#{0}>{1}</a> ", args.templateId, args.label))
}

editor.showExternalDialog(
'DocumentLinkBuilder.aspx',
null,
350,
300,
myCallbackFunction,
null,
'Insert Document Link',
true,
Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move,
true,
true);
};

function showConfirmRadWindow(sender, args) {

$find("<%=confirmWindow.ClientID %>").show();

$find("<%=RadButtonYes.ClientID %>").focus();

args.set_cancel(true);

}


function confirmResult(sender, args) {

var oWnd = $find("<%=confirmWindow.ClientID %>");

oWnd.close();

if (sender.get_text() == "Yes") {

//var CheckBoxContentChange = '<%=FormView1.FindControl("RadButtonContentChanged").ClientID%>'
//var CheckBoxContentChange = document.getElementById('<%=FormView1.FindControl("RadButtonContentChanged").ClientID%>');
var CheckBoxContentChange = '<%= DirectCast(FormView1.FindControl("RadButtonContentChanged").ClientID)%>'
alert(CheckBoxContentChange);

//$find("<%=RadButtonYes.ClientID %>").click();

}

}

//This code need to be deleted
//function confirmCallBackFn(arg) {
// alert(arg);
//}

</script>
</td>
<td style="padding-left:15px; vertical-align:top">
<asp:Panel ID="PanelBusinessLineDocumentContent" runat="server">
<div class="section" style="width:475px">
<div class="section-header">
<span class="label">LOB Applicable</span>
</div>
<div style="padding:5px">
<table>
<tr>
<td>
<telerik:RadComboBox ID="RadComboBoxBusinessLine" runat="server"
DataTextField="BusinessLineName" DataValueField="BusinessLineId" Width="300px">
</telerik:RadComboBox>
<telerik:RadButton ID="RadButtonAddBusinessLine" runat="server" Text="Add"
onclick="RadButtonAddBusinessLine_Click" Width="60px" CssClass="document-maint-detail-oneoff">
</telerik:RadButton>
<telerik:RadButton ID="RadButtonAddAllBusinessLine" runat="server" Text="Add All"
onclick="RadButtonAddAllBusinessLine_Click" Width="60px" CssClass="document-maint-detail-oneoff">
</telerik:RadButton>
</td>
</tr>
<tr>
<td style="padding-top:5px">
<telerik:RadGrid ID="RadGridBusinessLineDocumentContent" runat="server"
AutoGenerateColumns="False" GridLines="None" Height="330px" Width="460px">
<ClientSettings>
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
</ClientSettings>
<MasterTableView DataKeyNames="BusinessLineId">
<Columns>
<telerik:GridTemplateColumn>
<HeaderTemplate>
<asp:LinkButton ID="LinkButtonRemove" runat="server" Text="Remove"
OnClick="LinkButtonRemoveAllBusinessLines_Click" ToolTip="Click to remove all">
</asp:LinkButton>
</HeaderTemplate>
<ItemTemplate>
<asp:LinkButton ID="LinkButtonRemove" runat="server" CommandArgument='<%# Eval("BusinessLineId") %>'
Text="Remove" OnClick="LinkButtonRemoveBusinessLine_Click">
</asp:LinkButton>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="BusinessLineId" Visible="false" UniqueName="BusinessLineId" />
<telerik:GridBoundColumn DataField="BusinessLineName" HeaderText="Business Line" UniqueName="BusinessLineName" />
<telerik:GridBoundColumn DataField="ApplicableText" HeaderText="Applicable?" UniqueName="ApplicableText">
<ItemStyle Width="75px" />
</telerik:GridBoundColumn>
</Columns>
<NoRecordsTemplate>
<i><span style="padding-left:2px">No business lines apply</span></i>
</NoRecordsTemplate>
</MasterTableView>
</telerik:RadGrid>
</td>
</tr>
</table>
</div>
</div>
</asp:Panel>
</td>
</tr>
</table>
</div>
<br />
<telerik:RadButton ID="RadButtonSave" runat="server" Text="Save" ButtonType="LinkButton"
CommandName="Update" CausesValidation="true" CssClass="std-button"
OnClientClicking="showConfirmRadWindow"
>
</telerik:RadButton>
<telerik:RadButton ID="RadButtonDelete" runat="server" Text="Delete" ButtonType="LinkButton"
CommandName="Delete" CausesValidation="True" CssClass="std-button" OnClientClicking="CheckBeforeDelete">
</telerik:RadButton>&nbsp;
<telerik:RadButton ID="RadButtonCancel" runat="server" Text="Back" ButtonType="LinkButton"
CommandName="Cancel" CausesValidation="False" CssClass="std-button" onclick="RadButtonCancel_Click">
</telerik:RadButton>&nbsp;
<telerik:RadButton ID="RadButtonAddNew" runat="server" Text="Add New" ButtonType="LinkButton"
CausesValidation="False" CssClass="std-button" NavigateUrl="~/Content/ContentDetail.aspx">
</telerik:RadButton>
</EditItemTemplate>
<InsertItemTemplate>
<table>
<tr>
<td>
<span class="label">Version:&nbsp;</span>
</td>
<td>
<telerik:RadTextBox ID="RadTextBoxVersion" Width="200px" Runat="server" Enabled="false">
</telerik:RadTextBox>
</td>
</tr>
<tr>
<td>
<span class="label">Section Name:&nbsp;</span>
</td>
<td>
<telerik:RadTextBox ID="RadTextBoxContentName" Width="450px" Runat="server"
Text='<%# Bind("ContentName") %>'>
</telerik:RadTextBox>&nbsp;&nbsp;
<telerik:RadButton ID="RadButtonIsMandatory" runat="server" Text="Mandatory" ToggleType="CheckBox"
ButtonType="ToggleButton" Checked='<%# Bind("IsMandatory") %>' Width="60px">
</telerik:RadButton>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" Display="Dynamic"
ControlToValidate="RadTextBoxContentName" ErrorMessage="Enter a section name"
CssClass="validate-warning" ValidationGroup="OnInsert">
</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<span class="label">Section Title:&nbsp;</span>
</td>
<td>
<telerik:RadTextBox ID="RadTextBoxContentLabel" Width="450px" Runat="server"
Text='<%# Bind("ContentLabel") %>'>
</telerik:RadTextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" Display="Dynamic"
ControlToValidate="RadTextBoxContentLabel" ErrorMessage="Enter a section title"
CssClass="validate-warning" ValidationGroup="OnInsert">
</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<span class="label">Chapter:&nbsp;</span>
</td>
<td>
<telerik:RadComboBox ID="RadComboBoxChapter" runat="server"
DataTextField="ContentLabel" DataValueField="ContentId"
AutoPostBack="true" AppendDataBoundItems="true"
onselectedindexchanged="RadComboBoxChapter_SelectedIndexChanged">
<Items>
<telerik:RadComboBoxItem Text="" Value="-1" />
</Items>
</telerik:RadComboBox>
</td>
</tr>
<tr>
<td>
<span class="label">Heading:&nbsp;</span>
</td>
<td>
<telerik:RadComboBox ID="RadComboBoxHeading" runat="server"
DataTextField="ContentLabel" DataValueField="ContentId"
AutoPostBack="true" AppendDataBoundItems="true">
<Items>
<telerik:RadComboBoxItem Text="" Value="-1" />
</Items>
</telerik:RadComboBox>
</td>
</tr>
</table>
<div style="margin-top:10px">
<telerik:RadEditor ID="RadEditor1" runat="server" Content='<%# Bind("Content") %>'
StripFormattingOptions="MsWord,Span,Css,ConvertWordLists">
<CssFiles>
<telerik:EditorCssFile Value="~/Styles/radeditor.css" />
</CssFiles>
</telerik:RadEditor>
</div>
<br />
<telerik:RadButton ID="RadButtonSave" runat="server" Text="Save" ButtonType="LinkButton"
CommandName="Insert" CausesValidation="true" CssClass="std-button" ValidationGroup="OnInsert" >
</telerik:RadButton>&nbsp;
<telerik:RadButton ID="RadButtonCancel" runat="server" Text="Back" ButtonType="LinkButton"
CommandName="Cancel" CausesValidation="False" CssClass="std-button" onclick="RadButtonCancel_Click">
</telerik:RadButton>
</InsertItemTemplate>
<ItemTemplate>
<asp:HiddenField ID="HiddenField1" runat="server" Value='<%# Bind("VersionId") %>' />
<asp:HiddenField ID="HiddenField3" runat="server" Value='<%# Bind("ParentContentId") %>' />
<asp:HiddenField ID="HiddenField5" runat="server" Value='<%# Bind("Level") %>' />
<asp:HiddenField ID="HiddenField6" runat="server" Value='<%# Bind("CreatedBy") %>' />
<asp:HiddenField ID="HiddenField2" runat="server" Value='<%# Bind("CreatedDate") %>' />
<asp:HiddenField ID="HiddenField8" runat="server" Value='<%# Bind("LastUpdatedBy") %>' />
<asp:HiddenField ID="HiddenField7" runat="server" Value='<%# Bind("LastUpdatedDate") %>' />
<asp:HiddenField ID="HiddenField4" runat="server" Value='<%# Bind("SortNo") %>' />
<asp:HiddenField ID="HiddenField9" runat="server" Value='<%# Bind("HierarchySortNo") %>' />
<table>
<tr style="height:30px">
<td>
<span class="label">Context:&nbsp;</span>
</td>
<td>
<asp:Label ID="LabelParent" CssClass="label" runat="server" />
</td>
</tr>
<tr>
<td>
<span class="label">Section Type:</span>
</td>
<td>
<asp:Label ID="LabelSectionType" CssClass="label" Text='<%# Eval("SectionType") %>' runat="server" />
</td>
</tr>
<tr>
<td>
<span class="label">Section Name:&nbsp;</span>
</td>
<td>
<telerik:RadTextBox ID="RadTextBoxContentName" Width="450px" Runat="server"
Text='<%# Bind("ContentName") %>' Enabled="false">
</telerik:RadTextBox>
</td>
</tr>
<tr>
<td>
<span class="label">Section Title:&nbsp;</span>
</td>
<td>
<telerik:RadTextBox ID="RadTextBoxContentLabel" Width="450px" Runat="server"
Text='<%# Bind("ContentLabel") %>' Enabled="false">
</telerik:RadTextBox>
</td>
</tr>
<tr>
<td>
<span class="label">Mandatory:&nbsp;</span>
</td>
<td>
<asp:Label ID="Label3" CssClass="label" Text='<%# Eval("IsMandatoryText") %>' runat="server" />
</td>
</tr>
</table>
<table style="margin-top:10px">
</table>
<table style="margin-top:10px">
<tr>
<td>
<span class="label">Created:&nbsp;</span>
</td>
<td>
<asp:Label ID="Label1" CssClass="label" runat="server"
Text='<%# Eval("CreatedByUser.DisplayName") + " On " + Eval("CreatedDate") %>' />
</td>
<td style="padding-left:30px">
<span class="label">Last Updated:&nbsp;</span>
</td>
<td>
<asp:Label ID="Label2" CssClass="label" runat="server"
Text='<%# Eval("LastUpdatedByUser.DisplayName") + " On " + Eval("LastUpdatedDate") %>' />
</td>
</tr>
</table>
<div style="margin-top:10px">
<table>
<tr>
<td>
<telerik:RadEditor ID="RadEditor1" runat="server" Content='<%# Bind("Content") %>' Enabled="false"
StripFormattingOptions="MsWord,Span,Css,ConvertWordLists" Width="625px" ToolsFile="~/RadEditorToolsFile.xml" ImageManager-ViewPaths="~/UserImages">
<CssFiles>
<telerik:EditorCssFile Value="~/Styles/radeditor.css" />
</CssFiles>
<Tools>
<telerik:EditorToolGroup>
<telerik:EditorTool Name="InsertDocumentLink" Text="Insert Within Document Link" />
</telerik:EditorToolGroup>
</Tools>
</telerik:RadEditor>
</td>
<td style="padding-left:15px; vertical-align:top">
<asp:Panel ID="PanelBusinessLineDocumentContent" runat="server">
<div class="section" style="width:475px">
<div class="section-header">
<span class="label">LOB Applicable</span>
</div>
<div style="padding:5px">
<table>
<tr>
<td style="padding-top:5px">
<telerik:RadGrid ID="RadGridBusinessLineDocumentContent" runat="server"
AutoGenerateColumns="False" GridLines="None" Height="330px" Width="460px">
<ClientSettings>
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
</ClientSettings>
<MasterTableView DataKeyNames="BusinessLineId">
<Columns>
<telerik:GridBoundColumn DataField="BusinessLineId" Visible="false" UniqueName="BusinessLineId" />
<telerik:GridBoundColumn DataField="BusinessLineName" HeaderText="Business Line" UniqueName="BusinessLineName" />
<telerik:GridBoundColumn DataField="ApplicableText" HeaderText="Applicable?" UniqueName="ApplicableText">
<ItemStyle Width="75px" />
</telerik:GridBoundColumn>
</Columns>
<NoRecordsTemplate>
<i><span style="padding-left:2px">No business lines apply</span></i>
</NoRecordsTemplate>
</MasterTableView>
</telerik:RadGrid>
</td>
</tr>
</table>
</div>
</div>
</asp:Panel>
</td>
</tr>
</table>
</div>
<br />
<telerik:RadButton ID="RadButtonCancel" runat="server" Text="Back" ButtonType="LinkButton"
CommandName="Cancel" CausesValidation="False" CssClass="std-button" onclick="RadButtonCancel_Click">
</telerik:RadButton>
</ItemTemplate>
</asp:FormView>

<asp:EntityDataSource ID="DocumentContentDataSource" runat="server"
ConnectionString="name=CompConEntities" DefaultContainerName="CompConEntities"
EnableDelete="True" EnableFlattening="False" EnableInsert="True"
Include="ParentContent.ParentContent.ParentContent,LastUpdatedByUser,CreatedByUser,DocumentVersion,BusinessLineDocumentContents.BusinessLine,ChildContents"
EnableUpdate="True" EntitySetName="DocumentContents"
AutoGenerateWhereClause="true"
oncontextcreating="Generic_ContextCreating"
onupdating="DocumentContentDataSource_Updating"
oncontextdisposing="Generic_ContextDisposing"
oninserting="DocumentContentDataSource_Inserting"
oninserted="DocumentContentDataSource_Inserted">
<WhereParameters>
<asp:QueryStringParameter Name="ContentId" QueryStringField="cid" Type="Int32" />
</WhereParameters>
</asp:EntityDataSource>

<%-- Updated controls are added programmatically in prerender --%>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
</telerik:RadAjaxManager>

</asp:Content>

.CS file

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CompConData;
using Telerik.Web.UI;

public partial class ContentDetailPage : System.Web.UI.Page
{
static log4net.ILog _log = log4net.LogManager.GetLogger(typeof(ContentDetailPage));

CompConEntities _context = null;

protected bool IsReferrerHierarchy
{
get
{
object obj = ViewState["IsReferrerHierarchy"];
if (obj != null)
return (bool)obj;
else
return false;
}

set
{
ViewState["IsReferrerHierarchy"] = value;
}
}

protected int VersionId
{
get
{
object obj = ViewState["VersionId"];
if (obj != null)
return (int)obj;
else
return -1;
}

set
{
ViewState["VersionId"] = value;
}
}

/// <summary>
/// When in insert mode & from hierarchy, this will be the content id to restore
/// </summary>
protected string InsertCancelContentId
{
get
{
object obj = ViewState["InsertCancelContentId"];
if (obj != null)
return (string)obj;
else
return null;
}

set
{
ViewState["InsertCancelContentId"] = value;
}
}

protected void Page_Load(object sender, EventArgs e)
{
if (!SecurityController.IsInAdminRole()) throw new CustomSecurityException();

_context = new CompConEntities();

if (!Page.IsPostBack)
{
// Check if from hierarchy
if (Session["FromHierarchy"] != null)
{
this.IsReferrerHierarchy = true;
Session.Remove("FromHierarchy");
}

if (Request.QueryString[Constants.KeyContentId] != null)
{
this.Master.BreadcrumbLabelText = "You are here: Policy Document > Document Maintenance > Detail";

// Switch to read only template if version is in progress
this.SwitchToReadonlyIfShould(Convert.ToInt32(Request.QueryString[Constants.KeyContentId]));
}
else
{
this.Master.BreadcrumbLabelText = "You are here: Policy Document > Document Maintenance > Detail (New)";

this.FormView1.ChangeMode(FormViewMode.Insert);
}
}
}

protected void Page_Unload(object sender, EventArgs e)
{
if (_context != null) _context.Dispose();
}

private void SwitchToReadonlyIfShould(int contentId)
{
var result = _context.DocumentContents.Include("DocumentVersion")
.Where(c => c.ContentId == contentId);

if (result.Count() > 0)
{
if (result.First().DocumentVersion.VersionStatusCode !=
CompConCommon.Constants.STATUS_IN_PROGRESS)
{
this.FormView1.ChangeMode(FormViewMode.ReadOnly);
}
}
}

private void InitializeContentComboBoxes()
{
// Populate chapter level content
List<DocumentContent> documentContentList = _context.DocumentContents
.Where(c => c.DocumentVersion.VersionStatusCode == CompConCommon.Constants.STATUS_IN_PROGRESS)
.Where(c => c.Level == 1)
.OrderBy(c => c.SortNo).ToList();

RadComboBox radComboBox = (RadComboBox)this.FormView1.FindControl("RadComboBoxChapter");

radComboBox.DataSource = documentContentList;
radComboBox.DataBind();
}

private void InitializeContentComboBoxesFromContext(string contextAsCommaDelimitedStr)
{
// Get the context into array
char[] seps = { ',' };
string[] contextStrArr = contextAsCommaDelimitedStr.Split(seps);
this.InsertCancelContentId = contextStrArr[contextStrArr.Length - 1];

// Populate chapter level content
List<DocumentContent> documentContentList = _context.DocumentContents
.Where(c => c.DocumentVersion.VersionStatusCode == CompConCommon.Constants.STATUS_IN_PROGRESS)
.Where(c => c.Level == 1)
.OrderBy(c => c.SortNo).ToList();

RadComboBox radComboBoxChapter = (RadComboBox)this.FormView1.FindControl("RadComboBoxChapter");
radComboBoxChapter.DataSource = documentContentList;
radComboBoxChapter.DataBind();

if (radComboBoxChapter.Items.Any(i => i.Value == contextStrArr[0]))
{
radComboBoxChapter.SelectedValue = contextStrArr[0];
}

if (radComboBoxChapter.SelectedIndex > 0) // First value is empty
{
// Populate header level content
int chapterContentId = Convert.ToInt32(radComboBoxChapter.SelectedValue);

List<DocumentContent> headingContentList = _context.DocumentContents
.Where(c => c.ParentContentId == chapterContentId)
.OrderBy(c => c.SortNo).ToList();

RadComboBox radComboBoxHeading = (RadComboBox)this.FormView1.FindControl("RadComboBoxHeading");
radComboBoxHeading.DataSource = headingContentList;
radComboBoxHeading.DataBind();

if (contextStrArr.Length > 1)
{
if (radComboBoxHeading.Items.Any(i => i.Value == contextStrArr[1]))
{
radComboBoxHeading.SelectedValue = contextStrArr[1];
}
}
}
}

protected void RadButtonSave_Click(object sender, EventArgs e)
{

}

protected void RadButtonCancel_Click(object sender, EventArgs e)
{
if (this.IsReferrerHierarchy && this.FormView1.CurrentMode == FormViewMode.Edit)
{
Session[Constants.KeyContentId] = this.FormView1.DataKey["ContentId"];
Response.Redirect(string.Format("~/Content/ContentHierarchy.aspx?{0}={1}",
Constants.KeyVersionId,
this.VersionId));
}
else if (this.IsReferrerHierarchy && this.FormView1.CurrentMode == FormViewMode.Insert)
{
Session[Constants.KeyContentId] = this.InsertCancelContentId;
Response.Redirect(string.Format("~/Content/ContentHierarchy.aspx?{0}={1}",
Constants.KeyVersionId,
this.VersionId));
}
else
{
StateRestorer stateRestorer = new StateRestorer();
stateRestorer.MarkShouldRestore();

Response.Redirect("~/Content/ContentList.aspx");
}
}

protected void RadComboBoxChapter_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
{
if (e.OldValue == e.Value) return;

// Get new data for heading
int parentContentId = Convert.ToInt32(e.Value);

List<DocumentContent> contentList = _context.DocumentContents
.Where(c => c.DocumentVersion.VersionStatusCode == CompConCommon.Constants.STATUS_IN_PROGRESS)
.Where(c => c.ParentContentId == parentContentId)
.OrderBy(c => c.SortNo).ToList();

// Rebind heading
RadComboBox radComboBox = (RadComboBox)this.FormView1.FindControl("RadComboBoxHeading");
this.ClearAndRebind(radComboBox, contentList);
}

protected void Generic_ContextCreating(object sender, EntityDataSourceContextCreatingEventArgs e)
{
e.Context = _context;
}

protected void Generic_ContextDisposing(object sender, EntityDataSourceContextDisposingEventArgs e)
{
e.Cancel = true;
}

protected void FormView1_ItemDeleted(object sender, FormViewDeletedEventArgs e)
{
if (e.Exception == null)
{
if (this.IsReferrerHierarchy)
{
Response.Redirect(string.Format("~/Content/ContentHierarchy.aspx?{0}={1}",
Constants.KeyVersionId,
this.VersionId));
}
else
{
Response.Redirect("~/Content/ContentList.aspx");
}
}
}

protected void FormView1_PreRender(object sender, EventArgs e)
{
if (this.FormView1.CurrentMode == FormViewMode.Edit)
{
RadButton radButtonSave = this.FormView1.FindControl("RadButtonSave") as RadButton;
this.RadAjaxManager1.AjaxSettings.AddAjaxSetting(radButtonSave, this.FormView1, this.RadAjaxLoadingPanel1);
}
}

protected void FormView1_DataBound(object sender, EventArgs e)
{
if (this.FormView1.CurrentMode == FormViewMode.Edit)
{
DocumentContent documentContent = (DocumentContent)this.FormView1.DataItem;

// Set version info
this.VersionId = documentContent.VersionId;

// Sets the parent label
this.SetParentLabel(documentContent);

if (documentContent.IsMandatory)
{
Panel panelBusinessLineDocumentContent =
(Panel)this.FormView1.FindControl("PanelBusinessLineDocumentContent");

panelBusinessLineDocumentContent.Visible = false;
}
else
{
// Bind the business line grid
this.BindBusinessLineDocumentContentItems(documentContent);
}

// Disable delete if any child objects exist
if (documentContent.ChildContents != null && documentContent.ChildContents.Count() > 0)
{
RadButton radButton = (RadButton)this.FormView1.FindControl("RadButtonDelete");
radButton.Enabled = false;
}
}
else if (this.FormView1.CurrentMode == FormViewMode.Insert)
{
// Initialize content combo boxes. May have values passed from hierarchy
if (Session["ContentIdHierarchyContext"] != null)
{
this.InitializeContentComboBoxesFromContext(Session["ContentIdHierarchyContext"].ToString());
Session.Remove("ContentIdHierarchyContext");
}
else
{
this.InitializeContentComboBoxes();
}

// Set version info
var version = _context.DocumentVersions
.Where(v => v.VersionStatusCode == CompConCommon.Constants.STATUS_IN_PROGRESS)
.OrderByDescending(v => v.StartDate);

if (version == null || version.Count() == 0)
throw new ApplicationException("Must have version in progress for insert");

this.VersionId = version.First().VersionId;

RadTextBox radTextBox = (RadTextBox)this.FormView1.FindControl("RadTextBoxVersion");
radTextBox.Text = version.First().VersionName;
}
else
{
DocumentContent documentContent = (DocumentContent)this.FormView1.DataItem;

// Set version info
this.VersionId = documentContent.VersionId;

// Sets the parent label
this.SetParentLabel(documentContent);

if (documentContent.IsMandatory)
{
Panel panelBusinessLineDocumentContent =
(Panel)this.FormView1.FindControl("PanelBusinessLineDocumentContent");

panelBusinessLineDocumentContent.Visible = false;
}
else
{
// Bind the business line grid
this.BindBusinessLineDocumentContentItems(documentContent);
}
}
}

/// <summary>
/// Sets the parent information in the form for edit.
/// </summary>
private void SetParentLabel(DocumentContent documentContent)
{
List<string> parentList = new List<string>();

while (documentContent.ParentContent != null)
{
parentList.Add(documentContent.ParentContent.ContentLabel);
documentContent = documentContent.ParentContent;
}

parentList.Reverse();

Label labelParent = (Label)this.FormView1.FindControl("LabelParent");
labelParent.Text = string.Join(" > ", parentList);
}

protected void DocumentContentDataSource_Inserting(object sender, EntityDataSourceChangingEventArgs e)
{
DocumentContent content = (DocumentContent)e.Entity;

// Set user values
content.LastUpdatedBy = SecurityController.GetCurrentUserId();
content.CreatedBy = SecurityController.GetCurrentUserId();

// Set the version
content.VersionId = this.VersionId;

// Set the parent
RadComboBox radComboBox = (RadComboBox)this.FormView1.FindControl("RadComboBoxHeading");

if (radComboBox.SelectedIndex > 0)
{
content.ParentContentId = Convert.ToInt32(radComboBox.SelectedValue);
content.Level = 3;
}
else
{
radComboBox = (RadComboBox)this.FormView1.FindControl("RadComboBoxChapter");

if (radComboBox.SelectedIndex > 0)
{
content.ParentContentId = Convert.ToInt32(radComboBox.SelectedValue);
content.Level = 2;
}
else
{
var root = _context.DocumentContents.Where(c => c.Level == 0)
.Where(c => c.VersionId == this.VersionId);

content.ParentContentId = root.First().ContentId;
content.Level = 1;
}
}
}

protected void DocumentContentDataSource_Inserted(object sender, EntityDataSourceChangedEventArgs e)
{
if (e.Exception == null)
{
DocumentContent item = (DocumentContent)e.Entity;

if (this.IsReferrerHierarchy) Session["FromHierarchy"] = true;

Response.Redirect(string.Format("~/Content/ContentDetail.aspx?{0}={1}",
Constants.KeyContentId,
item.ContentId));
}
}

protected void DocumentContentDataSource_Updating(object sender, EntityDataSourceChangingEventArgs e)
{
DocumentContent content = (DocumentContent)e.Entity;

//This code need to be deletee
//if (!content.ContentChangedInd)
//{
// RadWindowManager1.RadConfirm("Server radconfirm: Are you sure?", "confirmCallBackFn", 330, 180, null, "Server RadConfirm");
//}
content.LastUpdatedBy = SecurityController.GetCurrentUserId();

this.MarkBusinessLineDocumentContentItemsForSave(content.IsMandatory);
}

private void ClearAndRebind(RadComboBox radComboBox, List<DocumentContent> contentList)
{
this.RemoveItemsExceptFirst(radComboBox);

radComboBox.DataSource = contentList;
radComboBox.DataBind();
}

private void RemoveItemsExceptFirst(RadComboBox radComboBox)
{
RadComboBoxItem item = radComboBox.Items[0];
radComboBox.Items.Clear();
radComboBox.Items.Insert(0, item);
}

// Temp method for checkbox check while content is updated
private void Update_Click(object sender, EventArgs e)
{

}

#region Business Line Document Content grid methods

/// <summary>
/// Data item for the business line document content grid.
/// </summary>
class BusinessLineGridItem
{
public int BusinessLineId { get; set; }

public string BusinessLineName { get; set; }

public string ApplicableText { get; set; }
}

protected void LinkButtonRemoveAllBusinessLines_Click(object sender, EventArgs e)
{
// New list to bind
List<BusinessLineGridItem> businessLineGridItemList = new List<BusinessLineGridItem>();

// Rebind the grid
this.BindBusinessLineDocumentContentGrid(businessLineGridItemList);

// Rebind the combo box
this.BindBusinessLineDocumentContentComboBoxArea(
businessLineGridItemList.Select(b => b.BusinessLineId).ToList());
}

protected void LinkButtonRemoveBusinessLine_Click(object sender, EventArgs e)
{
// Build the new grid item list
RadGrid radGrid = (RadGrid)this.FormView1.FindControl("RadGridBusinessLineDocumentContent");
List<BusinessLineGridItem> businessLineGridItemList = this.GetBusinessLineGridItems(radGrid);

// Get the business line id removed
LinkButton linkButton = sender as LinkButton;
int businessLineId = Convert.ToInt32(linkButton.CommandArgument);

// Get new list without that one item
businessLineGridItemList = businessLineGridItemList.Where(b => b.BusinessLineId != businessLineId).ToList();

// Rebind the grid
this.BindBusinessLineDocumentContentGrid(businessLineGridItemList);

// Rebind the combo box
this.BindBusinessLineDocumentContentComboBoxArea(
businessLineGridItemList.Select(b => b.BusinessLineId).ToList());
}

protected void RadButtonAddAllBusinessLine_Click(object sender, EventArgs e)
{
RadGrid radGrid = (RadGrid)this.FormView1.FindControl("RadGridBusinessLineDocumentContent");
List<BusinessLineGridItem> businessLineGridItemList = this.GetBusinessLineGridItems(radGrid);
List<int> businessLineGridItemIdList = businessLineGridItemList.Select(b => b.BusinessLineId).ToList();

List<BusinessLine> businessLineList = StaticDataCacheManager.GetBusinessLines();
foreach (BusinessLine businessLine in businessLineList)
{
if (!businessLineGridItemIdList.Contains(businessLine.BusinessLineId))
{
businessLineGridItemList.Add(new BusinessLineGridItem()
{
BusinessLineId = businessLine.BusinessLineId,
BusinessLineName = businessLine.BusinessLineName,
ApplicableText = "Yes",
});
}
}

// Rebind the grid
this.BindBusinessLineDocumentContentGrid(businessLineGridItemList);

// Rebind the combo box
this.BindBusinessLineDocumentContentComboBoxArea(businessLineGridItemList.Select(b => b.BusinessLineId).ToList());
}

protected void RadButtonAddBusinessLine_Click(object sender, EventArgs e)
{
// Get the selected business line the user wants to add
RadComboBox radComboBox = (RadComboBox)this.FormView1.FindControl("RadComboBoxBusinessLine");
int businessLineId = Convert.ToInt32(radComboBox.SelectedValue);
string businessLineName = radComboBox.Text;

// Create the new grid item & add to the existing grid item list
BusinessLineGridItem newItem = new BusinessLineGridItem();
newItem.BusinessLineId = businessLineId;
newItem.BusinessLineName = businessLineName;
newItem.ApplicableText = "Yes";

RadGrid radGrid = (RadGrid)this.FormView1.FindControl("RadGridBusinessLineDocumentContent");
List<BusinessLineGridItem> businessLineGridItemList = this.GetBusinessLineGridItems(radGrid);
businessLineGridItemList.Add(newItem);

// Rebind the grid
this.BindBusinessLineDocumentContentGrid(businessLineGridItemList);

// Rebind the combo box
this.BindBusinessLineDocumentContentComboBoxArea(businessLineGridItemList.Select(b => b.BusinessLineId).ToList());
}

private void MarkBusinessLineDocumentContentItemsForSave(bool newIsMandatoryValue)
{
int contentId = Convert.ToInt32(this.FormView1.DataKey["ContentId"]);

DocumentContent existingDocumentContent = _context.DocumentContents.Include("BusinessLineDocumentContents")
.Where(c => c.ContentId == contentId).First();

// Change from not mandatory -> mandatory
if (!existingDocumentContent.IsMandatory && newIsMandatoryValue)
{
// Mark all as mandatory
this.AllShouldBeThisApplicableCode(existingDocumentContent, "M");
}
// Change from mandatory -> not mandatory
else if (existingDocumentContent.IsMandatory && !newIsMandatoryValue)
{
// Mark all as applicable
this.AllShouldBeThisApplicableCode(existingDocumentContent, "Y");
}
// Content stays not mandatory
else if (!existingDocumentContent.IsMandatory && !newIsMandatoryValue)
{
RadGrid radGrid = (RadGrid)this.FormView1.FindControl("RadGridBusinessLineDocumentContent");
List<BusinessLineGridItem> newList = this.GetBusinessLineGridItems(radGrid);

this.MarkBusinessLineDocumentContentItemsForSave(existingDocumentContent,
newList.Select(b => b.BusinessLineId).ToList());
}
}

private void MarkBusinessLineDocumentContentItemsForSave(DocumentContent content, List<int> newBusinessIdList)
{
// Delete those that are currently associated but not in new list.
List<BusinessLineDocumentContent> existingBLDCList =
content.BusinessLineDocumentContents.ToList();

for (int i = 0; i < existingBLDCList.Count; i++)
{
BusinessLineDocumentContent item = existingBLDCList[i];

if (!newBusinessIdList.Contains(item.BusinessLineId))
{
_context.DeleteObject(item);
}
}

// Add those that are not associated but in new list
List<int> existingBLDCIntList =
existingBLDCList.Select(bldc => bldc.BusinessLineId).ToList();

foreach (int newBusinessLineId in newBusinessIdList)
{
if (!existingBLDCIntList.Contains(newBusinessLineId))
{
this.AddNewBusinessLineDocumentToContext(newBusinessLineId, content.ContentId, "Y");
}
}
}

private void AllShouldBeThisApplicableCode(DocumentContent content, string applicableCode)
{
// Mark all currently associated to the given applicable code
foreach (var item in content.BusinessLineDocumentContents)
{
if (item.ApplicableCode != applicableCode) item.ApplicableCode = applicableCode;
}

// Add any business lines that are not associated by getting those items in the all business line
// ids list that are not in the current business line id list
List<int> allBusinessLineIds =
StaticDataCacheManager.GetBusinessLines().Select(b => b.BusinessLineId).ToList();

List<int> unassociatedBusinessLineIds =
allBusinessLineIds.Except(content.BusinessLineDocumentContents.Select(bldv => bldv.BusinessLineId).ToList()).ToList();

foreach (int unassociatedBusinessLineId in unassociatedBusinessLineIds)
this.AddNewBusinessLineDocumentToContext(unassociatedBusinessLineId, content.ContentId, applicableCode);

}

private List<BusinessLineGridItem> GetBusinessLineGridItems(RadGrid radGrid)
{
List<BusinessLineGridItem> list = new List<BusinessLineGridItem>();

foreach (var item in radGrid.MasterTableView.Items)
{
GridDataItem gridDataItem = item as GridDataItem;

BusinessLineGridItem businessLineGridItem = new BusinessLineGridItem();
businessLineGridItem.BusinessLineId = Convert.ToInt32(gridDataItem["BusinessLineId"].Text);
businessLineGridItem.BusinessLineName = gridDataItem["BusinessLineName"].Text;
businessLineGridItem.ApplicableText = gridDataItem["ApplicableText"].Text;

list.Add(businessLineGridItem);
}

return list;
}

private void AddNewBusinessLineDocumentToContext(int businessLineId, int contentId, string applicableCode)
{
BusinessLineDocumentContent newBusinessLineDocumentContent = new BusinessLineDocumentContent();

newBusinessLineDocumentContent.BusinessLineId = businessLineId;
newBusinessLineDocumentContent.ContentId = contentId;
newBusinessLineDocumentContent.ApplicableCode = applicableCode;
newBusinessLineDocumentContent.LastUpdatedBy = SecurityController.GetCurrentUserId();

_context.AddToBusinessLineDocumentContents(newBusinessLineDocumentContent);
}

private void BindBusinessLineDocumentContentItems(DocumentContent documentContent)
{
// Get all applicable business lines
List<BusinessLineDocumentContent> applicableBLDCList = documentContent.BusinessLineDocumentContents.ToList();

// Bind the grid
List<BusinessLineGridItem> businessLineGridItemList =
(from bldc in applicableBLDCList
select
new BusinessLineGridItem {
BusinessLineId = bldc.BusinessLineId,
BusinessLineName = bldc.BusinessLine.BusinessLineName,
ApplicableText = bldc.ApplicableCodeDesc}).ToList();

this.BindBusinessLineDocumentContentGrid(businessLineGridItemList);

if (this.FormView1.CurrentMode == FormViewMode.Edit)
{
// Bind the combo box
this.BindBusinessLineDocumentContentComboBoxArea(
applicableBLDCList.Select(bldc => bldc.BusinessLineId).ToList());
}
}

private void BindBusinessLineDocumentContentGrid(List<BusinessLineGridItem> businessLineGridItemList)
{
// Bind to the grid
RadGrid radGrid = (RadGrid)this.FormView1.FindControl("RadGridBusinessLineDocumentContent");
radGrid.DataSource = businessLineGridItemList.OrderBy(b => b.BusinessLineName).ToList();
radGrid.DataBind();
}

private void BindBusinessLineDocumentContentComboBoxArea(List<int> applicableBLDCIdList)
{
List<BusinessLine> businessLineList = StaticDataCacheManager.GetBusinessLines();

List<BusinessLine> bindBusinessLineList = new List<BusinessLine>();

foreach (BusinessLine businessLine in businessLineList)
{
if (!applicableBLDCIdList.Contains(businessLine.BusinessLineId))
{
bindBusinessLineList.Add(businessLine);
}
}

// combobox
RadComboBox radComboBox = (RadComboBox)this.FormView1.FindControl("RadComboBoxBusinessLine");
radComboBox.DataSource = bindBusinessLineList.OrderBy(b => b.BusinessLineName).ToList();
radComboBox.DataBind();
radComboBox.Enabled = (bindBusinessLineList.Count() > 0);

// add business line button
RadButton radButtonAdd = (RadButton)this.FormView1.FindControl("RadButtonAddBusinessLine");
radButtonAdd.Enabled = (bindBusinessLineList.Count() > 0);

// add all business line button
RadButton radButtonAddAll = (RadButton)this.FormView1.FindControl("RadButtonAddAllBusinessLine");
radButtonAddAll.Enabled = (bindBusinessLineList.Count() > 0);
}

#endregion
}

Thanks,
S

Shyam
Top achievements
Rank 1
 answered on 11 Feb 2014
2 answers
126 views
Hi All,
         I have two detail Tables in my RadGrid . when I am exporting it in excel the bad image of paging icons are also getting exported in excel.
        these bad images are exporting only for those child grids which have data in it.  please let me know what I am doing wrong.  my code behind code is

I have also attached the excel sheet which having these bad images Please find them


  private void ExportDataToFile()
    {
        RadGrid.MasterTableView.ExpandCollapseColumn.Display = false;
        RadGrid1.MasterTableView.HierarchyLoadMode = GridChildLoadMode.Client;
        RadGrid1.MasterTableView.DetailTables[0].ExpandCollapseColumn.Display = false;
        RadGrid1.MasterTableView.DetailTables[0].DetailTables[0].ExpandCollapseColumn.Display = false;
        RadGrid1.MasterTableView.DetailTables[0].DetailTables[0].ShowFooter  = false;
        RadGrid1.MasterTableView.DetailTables[0].DetailTables[0].ShowGroupFooter= false;
        RadGrid1.MasterTableView.DetailTables[0].DetailTables[0].PagerStyle.Visible  = false;
        RadGrid1.ExportSettings.IgnorePaging = true;
        RadGrid1.MasterTableView.DetailTables[0].DetailTables[0].AllowPaging = false;
        //RadGrid1.MasterTableView.DetailTables[0].DetailTables[0].PagingManager. = false;
     
    }

protected void ExportToExcelImageButton_Click(object sender, EventArgs e)
    {
        ExportDataToFile();
        ExportToExcel(RadGrid1, "GridResults");
    }

RadGrid searchRadGrid, String fileName,)
        {
            if (isActionColumn)
                searchRadGrid.MasterTableView.Columns.FindByUniqueName(columnUniqueName).Display = false;
            searchRadGrid.MasterTableView.HierarchyDefaultExpanded = true;
            searchRadGrid.MasterTableView.DetailTables[0].DetailTables[0].AllowPaging =  false;
            searchRadGrid.MasterTableView.DetailTables[0].DetailTables[0].AllowCustomPaging  = false;
            if (searchRadGrid.MasterTableView.HasDetailTables)
            {
                foreach (GridTableView gridTableView in searchRadGrid.MasterTableView.DetailTables)
                {
                    // Added by partner CB to Fix defect 15597 
                    gridTableView.AllowPaging = false;
                    gridTableView.HierarchyDefaultExpanded = true;
                    gridTableView.AllowPaging = false;
                }
            }
            searchRadGrid.ExcelExportCellFormatting += new OnExcelExportCellFormattingEventHandler(SearchRadGrid_ExcelExportCellFormatting);
            searchRadGrid.ItemCreated += new GridItemEventHandler(RadGrid_ItemCreated);
            searchRadGrid.ExportSettings.ExportOnlyData = true;
            searchRadGrid.ExportSettings.IgnorePaging = true;
            searchRadGrid.ExportSettings.OpenInNewWindow = true;
            searchRadGrid.ExportSettings.FileName = fileName;
            _isExport = true;
            searchRadGrid.MasterTableView.ExportToExcel();
        }
Thanks







Shinu
Top achievements
Rank 2
 answered on 11 Feb 2014
1 answer
97 views
Hello,

Has anyone had this issue? I haven't changed my code but I have about 3 grid combobox filters and once I use one once, then they all stop working.

Here is the code I use for one that is the same for all of them:

<telerik:GridTemplateColumn ColumnGroupName="GeneralInformation" DataField="Status" AllowFiltering="True" HeaderText="Status" UniqueName="Status" HeaderTooltip="Status">
                               <ItemStyle HorizontalAlign="Center" />
                               <HeaderStyle Width="60px" BackColor="Navy" HorizontalAlign="Center" />
                               <EditItemTemplate>
                                   <telerik:RadDropDownList runat="server" ID="Statusdrop" DataValueField="StatusID"
                                       DataTextField="Status" DataSourceID="StatusFilter">
                                   </telerik:RadDropDownList>
                               </EditItemTemplate>
                               <FilterTemplate>
                                   <telerik:RadComboBox ID="StatusCombo" Skin="Silk" Height="100px" Width="50" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("Status").CurrentFilterValue %>'
                                       runat="server" OnClientSelectedIndexChanged="StatusIndexChanged">
                                       <Items>
                                           <telerik:RadComboBoxItem Text="All" Value="" />
                                           <telerik:RadComboBoxItem Text="G" Value="G" />
                                           <telerik:RadComboBoxItem Text="O" Value="O" />
                                           <telerik:RadComboBoxItem Text="Y" Value="Y" />
                                           <telerik:RadComboBoxItem Text="R" Value="R" />
                                           <telerik:RadComboBoxItem Text="M" Value="M" />                                       
 
                                       </Items>
                                   </telerik:RadComboBox>
                                   <telerik:RadScriptBlock ID="RadScriptBlock2" runat="server">
                                       <script type="text/javascript">
                                           function StatusIndexChanged(sender, args)
                                           {
                                               var tableView = window.$find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                               tableView.filter("Status", args.get_item().get_value(), "EqualTo");
                                           }
                                       </script>
                                   </telerik:RadScriptBlock>
                               </FilterTemplate>
                               <ItemTemplate>
                                   <asp:Label runat="server" ID="StatusLabel" Text='<%#Eval("Status") %>'></asp:Label>
                               </ItemTemplate>
                           </telerik:GridTemplateColumn>
Kostadin
Telerik team
 answered on 11 Feb 2014
1 answer
77 views
I built data entry form where user can type a numeric value and using JavaScript, it will update the rest of the grid and user will save the modified data from user entry and JS modification. The code was working under Win 7 x32bit.

I updated my OS to win 8 x64. After installing all the tools and moving the code from Win 7 to Win 8, I notice the code stop working. The code appeared to work correct when user enters data it auto calculated the cells with the JavaScript but when user click save only modified data by user is captured but javascript modified cells will not return the new value instead it return its original value.

I update my OS to be Win8 x32bit and retest the code and I found the issue still exists. Does RadGrid has issues with Win8?

I attached very simple example for the issue. Can you please help me figuring this issue out ?
 
ASP.NET CODE
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>
<html5>
<head runat="server">
<title></title>
<telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" />
</head>
<body>
<form id="form1" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<script type="text/javascript">
function OnBlurTxt(grid, args) {
var adj = document.getElementById('RadGrid1_ctl00_ctl04_txtPrice')
var adj2 = document.getElementById('RadGrid1_ctl00_ctl04_txtQnty')
var adj3 = document.getElementById('RadGrid1_ctl00_ctl04_txtTotal')
adj3.value = adj.value * adj2.value

}
</script>

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" EnableHistory="True" ViewStateMode="Enabled">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadGrid1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid1" UpdatePanelCssClass="" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="Button1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid1" UpdatePanelCssClass="" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<div>

</div>
<telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0" GridLines="None" AllowAutomaticUpdates="True">
<MasterTableView AutoGenerateColumns="False" DataKeyNames="Name" AllowAutomaticUpdates="true">
<Columns>
<telerik:GridBoundColumn DataField="Name" FilterControlAltText="Filter Name column" HeaderText="Name" SortExpression="Name" UniqueName="Name">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn HeaderText="Price" SortExpression="Price" UniqueName="Price" >
<ItemTemplate>
<telerik:RadNumericTextBox runat="server" NumberFormat-DecimalDigits="0" ID="txtPrice" Width="60px" DbValue='<%# Bind("Price") %>'
BackColor="Yellow" EnabledStyle-HorizontalAlign="Right" ViewStateMode="Enabled">
<ClientEvents OnBlur="OnBlurTxt" />
</telerik:RadNumericTextBox>
</ItemTemplate>
<ItemStyle Width="75px" HorizontalAlign=Right />
<HeaderStyle Width="75px" HorizontalAlign=Center />
</telerik:GridTemplateColumn>

<telerik:GridTemplateColumn HeaderText="Qnty" SortExpression="Qnty" UniqueName="Qnty" >
<ItemTemplate>
<telerik:RadNumericTextBox runat="server" NumberFormat-DecimalDigits="0" ID="txtQnty" Width="60px" DbValue='<%# Bind("Qnty") %>'
BackColor="Yellow" EnabledStyle-HorizontalAlign="Right" ViewStateMode="Enabled">
<ClientEvents OnBlur="OnBlurTxt" />
</telerik:RadNumericTextBox>
</ItemTemplate>
<ItemStyle Width="75px" HorizontalAlign=Right />
<HeaderStyle Width="75px" HorizontalAlign=Center />
</telerik:GridTemplateColumn>

<telerik:GridTemplateColumn HeaderText="Total" SortExpression="Total" UniqueName="Total">
<ItemTemplate>
<telerik:RadNumericTextBox runat="server" NumberFormat-DecimalDigits="3" ID="txtTotal" Width="60px" DbValue='<%# Bind("total") %>' BackColor="Yellow"
EnabledStyle-HorizontalAlign="Right" ViewStateMode="Enabled">
<ClientEvents OnBlur="OnBlurTxt" />
</telerik:RadNumericTextBox>
</ItemTemplate>
<ItemStyle Width="75px" HorizontalAlign=Right />
<HeaderStyle Width="75px" HorizontalAlign=Center />
</telerik:GridTemplateColumn>

</Columns>
</MasterTableView>
</telerik:RadGrid>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:RU_EnterpriseConnectionString %>" SelectCommand="SELECT [BrandID], [Name], [BrandOrderID] FROM [tblBrands]"></asp:SqlDataSource>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
</form>
</body>
</html5>


C# code
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;

public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

if (!IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.Add("Name");
dt.Columns.Add("Price");
dt.Columns.Add("Qnty");
dt.Columns.Add("Total");

object[] obj = new object[4] { "Test", "10", "5", "50" };
dt.Rows.Add(obj);
RadGrid1.DataSource=dt;
RadGrid1.Rebind();

}
}

protected void Button1_Click(object sender, EventArgs e)
{
//7-8-4
int i = 0;
string str="";
if (this.RadGrid1.Items[0] != null)
{

GridDataItem item = this.RadGrid1.Items[i];
RadNumericTextBox price = (RadNumericTextBox)item.Cells[3].FindControl("txtPrice");
RadNumericTextBox qnty = (RadNumericTextBox)item.Cells[4].FindControl("txtQnty");
RadNumericTextBox ttl = (RadNumericTextBox)item.Cells[4].FindControl("txtQnty");

str="Price="+price.Value.ToString() +" qnty=" +qnty.Value.ToString() + " ttl="+ttl.Value.ToString();

}

RadAjaxManager1.Alert(str);

}
}
Jayesh Goyani
Top achievements
Rank 2
 answered on 11 Feb 2014
1 answer
84 views
I have an issue like, when I try to drag and drop an image on to the editor, image drops as expected but resize border is shown above ribbon control.
This issue happens only in Internet explorer 9.
I have attached image of the issue that happens in Telerik demo site for your reference.

Marin Bratanov
Telerik team
 answered on 11 Feb 2014
1 answer
99 views
Hi
 i have a GridDateTime column but filtering on it is not working properly. I want to filtet the date values. Any idea?
Princy
Top achievements
Rank 2
 answered on 11 Feb 2014
1 answer
85 views
Hi.

I am trying to migrate the below code from radChart into an HtmlChart, but unfortunately I am having lots of issues doing so.  Any insight/help would be greatly appreciated, as well as any hints/tips/tricks for doing so.

<
telerik:RadChart ID="chartMain" runat="server" AutoLayout="True">
    <charttitle>
        <Appearance Position-AlignedPosition="Top">
        </Appearance>
        <TextBlock Text="">
        </TextBlock>
    </charttitle>
    <series>
        <telerik:ChartSeries Name="Index" Type="Line" DataYColumn="Close" DataLabelsColumn="OADate"
            DataXColumn="OADate">
            <Appearance ShowLabels="false">
            </Appearance>
        </telerik:ChartSeries>
        <telerik:ChartSeries Name="Index" Type="Line" DataYColumn="Close" DataLabelsColumn="OADate"
            DataXColumn="OADate">
            <Appearance ShowLabels="false">
            </Appearance>
        </telerik:ChartSeries>
    </series>
    <legend visible="False">
        <appearance visible="False" position-alignedposition="TopRight">
        </appearance>
    </legend>
    <appearance textquality="AntiAlias">
    </appearance>
    <plotarea xaxis-datalabelscolumn="OADate">
        <EmptySeriesMessage TextBlock-Text="Awaiting Data">
            <TextBlock Text="Awaiting Data">
            </TextBlock>
        </EmptySeriesMessage>
        <XAxis LayoutMode="Between" AutoScale="False">
            <Appearance ValueFormat="ShortTime" MajorGridLines-Visible="false" CustomFormat="HH">
            </Appearance>
        </XAxis>
        <YAxis IsZeroBased="false" AxisMode="Extended">
        </YAxis>
    </plotarea>
</telerik:RadChart>

Kind regards.
Leon
Danail Vasilev
Telerik team
 answered on 11 Feb 2014
3 answers
109 views
OK. Here's the deal.

I have a Grid that is defined with columns like this ...
1.<telerik:GridTemplateColumn UniqueName="DateTimeAdded" SortExpression="DateTimeAdded">
2.    <ItemTemplate>
3.        <div id="lblDateTime2"/>
4.    </ItemTemplate>
  5..
</telerik:GridTemplateColumn>

And I have some code behind that looks like this ...
1.switch (item.UniqueName)
2.                {
3.                    case "DateTimeAdded":
4.                        item.HeaderText = GetGlobalStringResource(GTypes.Task.TASK_LIST, GKeys.Task.TaskList.GRID_COLUMN_HEADER_TEXT_DATE_TIME);

Now, I've tried invoking this code in the OnLoad event and in both the Page and the Grid's OnPreRender event. In each case I can see the value of item.headerText being correctly set. However, it is NEVER rendered.

I can't call this during the ItemDataBound event as the grid is bound on the client.

I can't call this during the OnColumnCreated/OnConlumnCreating events as they aren't invoked.

I'd welcome any suggestions.



Konstantin Dikov
Telerik team
 answered on 11 Feb 2014
5 answers
234 views
Hi,

Can we use Ribbion Asp.net Ajax control in Asp.net Mvc project?

If yes, Please provide some sample.

Thanks & Regards
Ritesh Singh
Plamen
Telerik team
 answered on 11 Feb 2014
2 answers
399 views
Hi,

I am using version Q3 1114 2013 of your controls.

I want to use the slider for a date range, where the start and end dates vary so they have to be set at runtime.

I want to show ticks of the dates between the start and end date range, so the user will be able to see the timeline.  I am currently using SmallChange="7" and LargeChange="28" so that each small change is a week and each large change is 4 weeks.

If I understand correctly, I need to set ItemType="Item" and then add RadSliderItems to create the ticks.

Of course since I don't have a fixed date range, I will have to add RadSliderItems at runtime as well.

I have the slider working correctly until I programatically add the RadSliderItems.  If I add the RadSliderItems programatically, the RadSlider's SelectionStart and SelectionEnd are no longer set correctly.  Instead of them being set to the leftmost and rightmost dates in the range, they are both set to the far right.

My first question is:  Do you have an example of doing this?  Please don't refer me to your online demo for adding RadSliderItems.  It doesn't show how to do all of this programatically using dates.

Here is my code.  Can you tell me what I might be doing wrong, that would cause my SelectionStart and SelectionEnd to be wrong when I add my RadSliderItems?
If I comment out the code that adds the RadSliderItems, the code below that (that sets the minimum / maximum / selectionstart / selectionend) works fine and the slider works fine.

Dim firstDate As Date = Today
Dim lastDate As Date = Today

If (Not Page.IsPostBack) Then
firstDate = filteredTaskList(0).apTaskPlannedStart
lastDate = filteredTaskList(filteredTaskList.Count - 1).apTaskPlannedEnd

Do Until firstDate >= lastDate
Dim rsi As New RadSliderItem(firstDate.ToShortDateString, firstDate.ToShortDateString)
RadSlider1.Items.Add(rsi)
firstDate = firstDate.AddDays(28)
Loop
End If

If (Not Page.IsPostBack) Then
RadSlider1.MinimumValue = CInt(filteredTaskList(0).apTaskPlannedStart.ToOADate)
RadSlider1.MaximumValue = CInt(filteredTaskList(filteredTaskList.Count - 1).apTaskPlannedEnd.ToOADate)

RadSlider1.SelectionStart = CInt(filteredTaskList(0).apTaskPlannedStart.ToOADate)
RadSlider1.SelectionEnd = CInt(filteredTaskList(filteredTaskList.Count - 1).apTaskPlannedEnd.ToOADate)
Else
filteredTaskList = From tasks In filteredTaskList _
 Where tasks.apTaskPlannedStart >= Date.FromOADate(RadSlider1.SelectionStart.ToString) AndAlso tasks.apTaskPlannedEnd <= Date.FromOADate(RadSlider1.SelectionEnd.ToString) _
 Select tasks
End If

Regards,
Brent
Brent Hetland
Top achievements
Rank 1
 answered on 11 Feb 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?