Telerik Forums
UI for ASP.NET AJAX Forum
6 answers
197 views
I am using export to excel of RadGrid with html format.

When I export the RadGird to Excel, I want Grid Header rows to repeat across pages when the content exceeds more than one page in exported file.
Same is needed when I use Format= "ExcelML"

Please help me.
 
Kostadin
Telerik team
 answered on 14 Oct 2013
1 answer
225 views
Hello,

I was observing our intranet site in fiddler2 and saw a 404 #Err for a core handler. May I please have any suggestion to narrow this problem, down ? I'm attaching the trace if that helps. this happens on most of the pages of our application but this screen shot is for /Dashboard/Dashboard.aspx page in specific.

Application is running on ASP.NET 4.0

Thanks in advance for any help / constructive suggestions ,
-Aarsh
Aarsh
Top achievements
Rank 1
 answered on 14 Oct 2013
1 answer
256 views
Hi,

I'm using 2 grids on one page.
Selecting a row in the upper grid will show data in the lower grid.
This seems to work fine the way it is now.

In the lower grid I would like to use a command or button column to edit and delete items.
I've implemented these, but when clicking on of them the program will crash with the following error:

Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.


The solution is that you need to use the NeedDataSource event, but I don't know how.
When using this, clicking a row on the upper grid will not update the lower grid.

So how can I implement this so the edit/delete buttons functions will also work?

Thanks,
Egbert

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
    CodeFile="Tasks.aspx.cs" Inherits="Tasks" %>
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div style="padding: 1%; width: 98%">
        <telerik:RadPanelBar ID="RadPanelBar1" runat="server" Width="100%">
            <Items>
                <telerik:RadPanelItem Text="Task details" runat="server">
                    <Items>
                        <telerik:RadPanelItem runat="server">
                            <ItemTemplate>
                                <table align="center">
                                    <tr>
                                        <td>
                                            Project Title
                                        </td>
                                        <td>
                                            Project Nr
                                        </td>
                                        <td>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <telerik:RadTextBox ID="RadTextBoxProjectTitle" runat="server" Width="300px" Enabled="false">
                                            </telerik:RadTextBox>
                                        </td>
                                        <td>
                                            <telerik:RadTextBox ID="RadTextBoxProjectNr" runat="server" Width="200px" Enabled="false">
                                            </telerik:RadTextBox>
                                        </td>
                                        <td>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <br />
                                        </td>
                                        <td>
                                        </td>
                                        <td>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Title
                                        </td>
                                        <td>
                                            Nr
                                        </td>
                                        <td>
                                            Subsidy
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <telerik:RadTextBox ID="RadTextBoxTitle" runat="server" Width="300px">
                                            </telerik:RadTextBox>
                                        </td>
                                        <td>
                                            <telerik:RadTextBox ID="RadTextBoxNr" runat="server" Width="200px">
                                            </telerik:RadTextBox>
                                        </td>
                                        <td>
                                            <telerik:RadDropDownList ID="RadDropDownSubsidy" runat="server" Width="200px">
                                            </telerik:RadDropDownList>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Description
                                        </td>
                                        <td align="right">
                                            Estimated Hours
                                            <telerik:RadMaskedTextBox ID="RadMaskedTextBox1" runat="server" Width="60px">
                                            </telerik:RadMaskedTextBox>
                                        </td>
                                        <td align="right">
                                            % Done
                                            <telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server" Width="60px">
                                            </telerik:RadNumericTextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="3">
                                            <telerik:RadTextBox ID="RadTextBox1" runat="server" TextMode="MultiLine" Height="60"
                                                Width="100%">
                                            </telerik:RadTextBox>
                                        </td>
                                        <td>
                                        </td>
                                        <td>
                                        </td>
                                    </tr>
                                </table>
                            </ItemTemplate>
                        </telerik:RadPanelItem>
                    </Items>
                </telerik:RadPanelItem>
            </Items>
        </telerik:RadPanelBar>
        <br />
        <b>Projects</b>
        <telerik:RadGrid ID="RadGridProjects" runat="server" AllowPaging="True" ActiveItemStyle-Wrap="True"
            OnItemCreated="RadGrid1_ItemCreated" OnPreRender="RadGrid1_ItemPreRender" ShowStatusBar="true"
            AllowSorting="True" AllowMultiRowEdit="true" AutoGenerateColumns="false" OnSelectedIndexChanged="RadGridProjects_SelectedIndexChanged"
            OnNeedDataSource="RadGridProjects_NeedDataSource">
            <MasterTableView PageSize="5">
                <Columns>
                    <telerik:GridButtonColumn Text="Select" CommandName="Select">
                    </telerik:GridButtonColumn>
                    <%--                <telerik:GridButtonColumn Text="Deselect" CommandName="Deselect">
                </telerik:GridButtonColumn>
                    --%>
                    <telerik:GridTemplateColumn UniqueName="CheckBoxTemplateColumn" Display="false">
                        <HeaderTemplate>
                            <asp:CheckBox ID="headerChkbox" OnCheckedChanged="ToggleSelectedState" AutoPostBack="True"
                                runat="server"></asp:CheckBox>
                        </HeaderTemplate>
                        <ItemTemplate>
                            <asp:CheckBox ID="CheckBox1" OnCheckedChanged="ToggleRowSelection" AutoPostBack="True"
                                runat="server"></asp:CheckBox>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridBoundColumn DataField="id" HeaderText="ID" UniqueName="id" Display="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="nr" HeaderText="Nr" UniqueName="nr">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="title" HeaderText="Title" UniqueName="title">
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
            <ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="true">
            </ClientSettings>
        </telerik:RadGrid>
        <p>
        </p>
        <b>Tasks</b>
        <telerik:RadGrid ID="RadGridTasks" runat="server" AllowPaging="True" ActiveItemStyle-Wrap="True"
            OnItemCreated="RadGridTasks_ItemCreated" OnPreRender="RadGridTasks_ItemPreRender"
            ShowStatusBar="true" AllowSorting="True" AllowMultiRowEdit="true" AutoGenerateColumns="false"
            OnSelectedIndexChanged="RadGridTasks_SelectedIndexChanged" AllowAutomaticInserts="true"
            OnEditCommand="RadGridTasks_EditCommand" OnItemCommand="RadGridTasks_ItemCommand"
            OnNeedDataSource="RadGridTasks_NeedDataSource">
            <MasterTableView PageSize="10" NoMasterRecordsText="No data">
                <Columns>
                    <telerik:GridButtonColumn UniqueName="EditCommand" CommandName="Edit" ButtonType="PushButton"
                        Text="Edit">
                    </telerik:GridButtonColumn>
                    <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                        <ItemStyle CssClass="MyImageButton"></ItemStyle>
                    </telerik:GridEditCommandColumn>
                    <telerik:GridButtonColumn Text="Select" CommandName="Select">
                    </telerik:GridButtonColumn>
                    <%--                <telerik:GridButtonColumn Text="Deselect" CommandName="Deselect">
                </telerik:GridButtonColumn>
                    --%>
                    <telerik:GridTemplateColumn UniqueName="CheckBoxTemplateColumn" Display="false">
                        <HeaderTemplate>
                            <asp:CheckBox ID="headerChkbox_RadGRidTasks" OnCheckedChanged="RadGridTasks_ToggleSelectedState"
                                AutoPostBack="True" runat="server"></asp:CheckBox>
                        </HeaderTemplate>
                        <ItemTemplate>
                            <asp:CheckBox ID="CheckBox_RadGRidTasks" OnCheckedChanged="RadGridTasks_ToggleRowSelection"
                                AutoPostBack="True" runat="server"></asp:CheckBox>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridBoundColumn DataField="id" HeaderText="ID" UniqueName="idTask" Display="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="nr" HeaderText="Nr" UniqueName="nrTask">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="title" HeaderText="Title" UniqueName="titleTask">
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
            <ClientSettings EnableRowHoverStyle="true">
            </ClientSettings>
        </telerik:RadGrid>
        <p>
        </p>
        <center>
            <telerik:RadButton ID="RadButtonAddTask" runat="server" Text="Add Task" OnClick="RadButtonAddTask_Click">
            </telerik:RadButton>
        </center>
        <telerik:RadWindow ID="RadWindowWarning" VisibleOnPageLoad="false" Title="Warning"
            runat="server" Modal="true" AutoSize="false" Width="400" Height="160" VisibleTitlebar="true"
            VisibleStatusbar="False" Behaviors="None">
            <ContentTemplate>
                <p style="text-align: center;">
                    <asp:Label runat="server" ID="labelWindow" Text="Please select a project!"></asp:Label>
                </p>
                <p style="padding: 10px; text-align: center;">
                    <telerik:RadButton ID="ButtonWindowOK" Text="OK" AutoPostBack="true" runat="server"
                        OnClick="ButtonWindowOK_Click" />
                </p>
            </ContentTemplate>
        </telerik:RadWindow>
    </div>
</asp:Content>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using Ris.Classes;
using System.Data;
 
public partial class Tasks : System.Web.UI.Page
{
    private string userID = string.Empty;
    private string projectID = string.Empty;
 
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session.Count == 0 || Session["Login"] == null || Session["Login"].ToString() == "No")
        {
            Response.Redirect("Login.aspx");
        }
 
        this.userID = Session["UserID"].ToString();
        this.projectID = Session["ProjectID"].ToString();
 
        this.ShowProjects();
 
        if (this.projectID != "0")
        {
            this.ShowTasks();
        }
    }
 
    protected void RadGridTasks_NeedDataSource(object sender, EventArgs e)
    {
        // this.ShowTasks();
    }
 
    protected void RadGridProjects_NeedDataSource(object sender, EventArgs e)
    {
        // this.ShowProjects();
    }
 
    private void ShowProjects()
    {
        DbProjects dbProject = new DbProjects();
 
        DataSet dataSet = dbProject.GetAllProjects(DbProjects.prjSelection.User, this.userID);
 
        this.RadGridProjects.DataSource = dataSet;
        this.RadGridProjects.DataBind();
    }
 
    private void ShowTasks()
    {
        this.projectID = Session["ProjectID"].ToString();
        if (this.projectID == "0")
        {
            return;
        }
 
        DbTasks dbTask = new DbTasks();
 
        DataSet dataSet = dbTask.GetAllTasks(DbTasks.tskSelection.User, this.projectID, this.userID);
 
        this.RadGridTasks.DataSource = dataSet;
        this.RadGridTasks.DataBind();
 
        this.RadGridProjects.Rebind();
    }
 
    protected void RadGridProjects_SelectedIndexChanged(object sender, EventArgs e)
    {
        GridDataItem dataItem = (GridDataItem)RadGridProjects.SelectedItems[0];
 
        if (dataItem != null)
        {
            Session["ProjectID"] = dataItem["id"].Text;
            this.ShowTasks();
        }
    }
 
    protected void ToggleSelectedState(object sender, EventArgs e)
    {
        CheckBox headerCheckBox = (sender as CheckBox);
        foreach (GridDataItem dataItem in RadGridProjects.MasterTableView.Items)
        {
            (dataItem.FindControl("CheckBox1") as CheckBox).Checked = headerCheckBox.Checked;
            dataItem.Selected = headerCheckBox.Checked;
        }
    }
 
    protected void RadGridTasks_ToggleSelectedState(object sender, EventArgs e)
    {
        CheckBox headerCheckBox = (sender as CheckBox);
        foreach (GridDataItem dataItem in RadGridTasks.MasterTableView.Items)
        {
            (dataItem.FindControl("CheckBox1") as CheckBox).Checked = headerCheckBox.Checked;
            dataItem.Selected = headerCheckBox.Checked;
        }
    }
 
    protected void ToggleRowSelection(object sender, EventArgs e)
    {
        ((sender as CheckBox).NamingContainer as GridItem).Selected = (sender as CheckBox).Checked;
    }
 
    protected void RadGridTasks_ToggleRowSelection(object sender, EventArgs e)
    {
        ((sender as CheckBox).NamingContainer as GridItem).Selected = (sender as CheckBox).Checked;
    }
 
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            e.Item.PreRender += new EventHandler(RadGrid1_ItemPreRender);
        }
    }
 
    protected void RadGridTasks_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            e.Item.PreRender += new EventHandler(RadGridTasks_ItemPreRender);
        }
    }
 
    protected void RadGridTasks_SelectedIndexChanged(object sender, EventArgs e)
    {
        GridDataItem dataItem = (GridDataItem)RadGridTasks.SelectedItems[0];
 
        if (dataItem != null)
        {
            //Session["ProjectID"] = dataItem["id"].Text;
            //this.ShowTasks();
        }
    }
 
    protected void RadGrid1_ItemPreRender(object sender, EventArgs e)
    {
        try
        {
            ((sender as GridDataItem)["CheckBoxTemplateColumn"].FindControl("CheckBox1") as CheckBox).Checked = (sender as GridDataItem).Selected;
        }
        catch
        {
        }
    }
 
    protected void RadGridTasks_ItemPreRender(object sender, EventArgs e)
    {
        try
        {
            ((sender as GridDataItem)["CheckBoxTemplateColumn"].FindControl("CheckBox1") as CheckBox).Checked = (sender as GridDataItem).Selected;
        }
        catch
        {
        }
    }
 
    protected void ButtonWindowOK_Click(object sender, EventArgs e)
    {
        this.RadWindowWarning.VisibleOnPageLoad = false;
    }
 
    protected void RadGridTasks_EditCommand(object source, GridCommandEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = (GridDataItem)e.Item;
            //string id = item.GetDataKeyValue("id").ToString();
            //string id = item["id"].ToString();
        }
    }
 
    protected void RadGridTasks_ItemCommand(object source, GridCommandEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = (GridDataItem)e.Item;
            int index = e.Item.ItemIndex;
            // string id = item.GetDataKeyValue("id").ToString();
            //string id = item["id"].ToString();
        }
    }
 
    protected void RadButtonAddTask_Click(object sender, EventArgs e)
    {
        if (Session["ProjectID"].ToString() == "0")
        {
            this.RadWindowWarning.VisibleOnPageLoad = true;
        }
        else
        {
            Session["EditTaskType"] = EditType.Add;
            Response.Redirect("TaskItem.aspx");
        }
    }
}
Eyup
Telerik team
 answered on 14 Oct 2013
2 answers
264 views
Hello!

We are have a small problem with our site. Leaving certain pages idle for longer time and then clicking certain controls,
gives a user the following error:

Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.

Details: Error parsing near '�'.

On the server side, the error is as follows:

System.Web.UI.ViewStateException: Invalid viewstate. 
Client IP: 192.168.225.147
Port: 50670
Referer: http://10.176.81.70/List.aspx
Path: /List.aspx
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0


I noticed that the error happens after the time that is set under Idle time-out (minutes) under application pool advanced settings.
As far as potential reasons (Response.Write(), response filters, HttpModules, or server trace is enabled), I can say that they are not the problem.

The fact is also that Windows Authentication is used so user "is" logged in as long as the browser is opened.
In Forms Authentication the problem does not occur since user is logged out after certain amount of time...

I'm attaching the code. Can you, please, tell me, what could be the problem.


<%@ Page Language="C#" MasterPageFile="~/StorePortal.Master" AutoEventWireup="true" CodeFile="List.aspx.cs" Inherits="StorePortal.List"
    Title="<%$ Resources:GRes, Companies %>" %>
<%@ Register Src="~/Controls/SearchBox.ascx" TagName="SearchBox" TagPrefix="MakeIT" %>
<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="Server">
    <meta content="Desc!" name="description" />
    <meta content="Keywords" name="keywords" />
    <link id="RadGridCSS" rel="stylesheet" type="text/css" href="<%= SkinFolder %>/styles/RadControls/Grid.MakeIT.css" />
</asp:Content>
<asp:Content ID="pageAdd" ContentPlaceHolderID="pageAdd" runat="server">
    <asp:ScriptManagerProxy ID="ScriptManagerProxy" runat="server" />
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="Companies">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="Companies" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <MakeIT:SearchBox ID="searchBox" runat="server" SearchGridId="Companies"/>
    <div id="content" class="home">
        <div class="wrap">
            <telerik:RadGrid ID="Companies" runat="server" AllowSorting="true" AutoGenerateColumns="false" OnNeedDataSource="Companies_NeedDataSource" Skin="MakeIT"
                EnableEmbeddedSkins="false" ImagesPath="<%# this.ImagesPath %>" OnItemCommand="Companies_ItemCommand" OnItemDataBound="Companies_ItemDataBound">
                <MasterTableView DataKeyNames="CompanyHash" CommandItemDisplay="Top" Dir="<%$ Resources:GRes, _DisplayDirection %>">
                    <HeaderStyle Height="40" />
                    <CommandItemTemplate>
 
                        <table class="rgCommandTable">
                            <tr>
                                <td>
                                    <asp:Label ID="Companies" runat="server" Text="<%$ Resources:GRes, Companies %>" CssClass="caption" />
                                </td>
                                <td>
                                    <div class="float_right">
                                        <MakeIT:FancyButton ID="AddButton" runat="server" Type="Add" CommandName="InitInsert" CausesValidation="false" Visible="<%# this.UserCanAddCompany %>" />
                                    </div>
                                </td>
                            </tr>
                        </table>
 
                    </CommandItemTemplate>
                    <Columns>
                        <telerik:GridHyperLinkColumn UniqueName="CompanyName" HeaderText="<%$ Resources:GRes, Name %>" DataNavigateUrlFields="CompanyHash" DataNavigateUrlFormatString="Overview.aspx?CompanyID={0}"
                            DataTextField="Name" DataTextFormatString="{0}" />
                        <telerik:GridBoundColumn DataField="Address" HeaderText="<%$ Resources:GRes, Address %>" />
                        <telerik:GridBoundColumn DataField="Telephone" HeaderText="<%$ Resources:GRes, Telephone %>" />
                        <telerik:GridDateTimeColumn DataField="dateProvisioned" HeaderText="<%$ Resources:GRes, DateProvisioned %>" />
                        <telerik:GridEditCommandColumn UniqueName="EditColumn" ButtonType="ImageButton" HeaderStyle-Width="43px" />
                        <telerik:GridButtonColumn CommandName="Delete" ButtonType="ImageButton" HeaderStyle-Width="43px" UniqueName="DeleteColumn" ConfirmTextFormatString="<%$ Resources:GRes, QuestionDeleteCompany %>"
                            ConfirmTextFields="Name" />
                    </Columns>
                    <NoRecordsTemplate>
                        <asp:Literal ID="NoRecords" runat="server" Text="<%$ Resources:GRes, NoRecords %>" />
                    </NoRecordsTemplate>
                </MasterTableView>
            </telerik:RadGrid>
 
            <br />
            <telerik:RadGrid ID="PendingCompanies" runat="server" AllowSorting="true" AutoGenerateColumns="false" OnNeedDataSource="PendingCompanies_NeedDataSource" Skin="MakeIT"
                EnableEmbeddedSkins="false" ImagesPath="<%# this.ImagesPath %>">
                <MasterTableView DataKeyNames="importId" CommandItemDisplay="Top" Dir="<%$ Resources:GRes, _DisplayDirection %>">
                    <HeaderStyle Height="40" />
                    <CommandItemTemplate>
 
                        <table class="rgCommandTable">
                            <tr>
                                <td>
                                    <asp:Label ID="Companies" runat="server" Text="Pending VAR Companies" CssClass="caption" />
                                </td>
                            </tr>
                        </table>
 
                    </CommandItemTemplate>
                    <Columns>
                        <telerik:GridHyperLinkColumn UniqueName="CompanyName" HeaderText="<%$ Resources:GRes, Name %>" DataNavigateUrlFields="ImportId" DataNavigateUrlFormatString="NewCompany.aspx?importId={0}&CompanyID=new"
                            DataTextField="CompanyName" DataTextFormatString="{0}" />
                        <telerik:GridTemplateColumn UniqueName="Address" HeaderText="<%$ Resources:GRes, Address %>">
                            <ItemTemplate>
                                <%# Eval("Address1") %>, <%# Eval("Address2") %>, <%# Eval("City") %>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridBoundColumn DataField="Email" HeaderText="<%$ Resources:GRes, Email %>" />
                        <telerik:GridBoundColumn DataField="Reseller" HeaderText="Reseller" />
                        <telerik:GridBoundColumn DataField="OrderDate" HeaderText="Order date" />
                    </Columns>
                    <NoRecordsTemplate>
                        <asp:Literal ID="NoRecords" runat="server" Text="<%$ Resources:GRes, NoRecords %>" />
                    </NoRecordsTemplate>
                </MasterTableView>
            </telerik:RadGrid>
        </div>
    </div>
</asp:Content>
<asp:Content ID="addonJS" ContentPlaceHolderID="addonJS" runat="server">
</asp:Content>


using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using UOCommonLib;
using Telerik.Web.UI;
using Store.Data;
 
namespace CompanyPortal
{
    public partial class List : BasePage
    {
        protected bool UserCanAddCompany { get { return ACL.HasAccessToAny("CompanyAdd"); } }
 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!UOPortalLib.UOPortalUiSettings.showElement("Global/DisplayVARCompanies"))
                PendingCompanies.Visible = false;
        }
 
        protected void Page_LoadComplete(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
                Authorize();
        }
 
        public RadGrid SearchGrid { get { return Companies; } }
 
 
        protected void Companies_ItemCommand(object sender, GridCommandEventArgs e)
        {
            if (e.CommandName == "InitInsert")
            {
                if (UserCanAddCompany) Response.Redirect("NewCompany.aspx?CompanyID=new");
                else e.Canceled = true;
            }
            else if (e.CommandName == "Delete")
            {
                string CompanyHash = ((GridDataItem)e.Item).OwnerTableView.DataKeyValues[e.Item.ItemIndex]["CompanyHash"].ToString();
 
                using (DBAppl dbm = new DBAppl())
                {
                    UOContext con = new UOContext(dbm.GetSqlConnection());
                    con.BeginTransaction();
 
                    try
                    {
                        int reqId = CompanyRequest.DeleteCompanyRequest(Session["UserID"].ToString(), CompanyHash, con);
                        // ModuleManager.RequestAction();
                        con.Commit();
                    }
                    catch (Exception ex)
                    {
                        con.Rollback();
                        logger.Error("DeleteCompany", ex);
                        Response.Redirect("~/Error.aspx", true);
                    }
                }
            }
            else if (e.CommandName == "Edit")
            {
                string CompanyHash = ((GridDataItem)e.Item).OwnerTableView.DataKeyValues[e.Item.ItemIndex]["CompanyHash"].ToString();
                Response.Redirect("Company.aspx?CompanyID=" + CompanyHash);
            }
        }
 
        protected void Companies_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem dataItem = (GridDataItem)e.Item;
                DataRowView row = (DataRowView)e.Item.DataItem;
                int CompanyID = (int)row["CompanyID"];
                string CompanyHash = row["CompanyHash"].ToString();
                string status = row["status"].ToString().Trim();
                int pendingUserChanges = (int)row["pendingUserChanges"];
                int pendingCompanyChanges = (int)row["pendingCompanyChanges"];
                int userCount = (int) row["userCount"];
                bool hasPermissionUserRead = (int)row["hasPermissionUserRead"] == 1;
 
                ImageButton editButton = (ImageButton)dataItem["EditColumn"].Controls[0];
                ImageButton deleteButton = (ImageButton)dataItem["DeleteColumn"].Controls[0];
 
                if (status != "ACT" || pendingCompanyChanges > 0)
                {
                    editButton.Visible = false;
                    deleteButton.Visible = false;
                }
 
                if (pendingUserChanges > 0 || userCount > 0)
                    deleteButton.Visible = false;
 
                if (status != "ACT" || !hasPermissionUserRead)
                {
                    dataItem["CompanyName"].Controls.RemoveAt(0);
                    Label companyName = new Label();
                    companyName.Text = row["Name"].ToString();
                    dataItem["Companyname"].Controls.AddAt(0, companyName);
                }
            }
        }
 
        protected void Companies_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            using (DBAppl dbm = new DBAppl())
            {
 
                // Gets all companies the user has access to (= UserRead)
                SqlCommand command = new SqlCommand("EXEC fa_getAllUserCompanies @UserID,@Filter", dbm.GetSqlConnection());
                SqlParameter sqlParam = new SqlParameter("@UserID", SqlDbType.NVarChar);
                sqlParam.Value = ACL.currentUser;
                command.Parameters.Add(sqlParam);
 
                logger.Debug("Filter=" + searchBox.Text);
                command.Parameters.Add(new SqlParameter("@Filter", searchBox.Text));
 
                SqlDataAdapter adapter = new SqlDataAdapter(command);
                DataTable dt = new DataTable();
                adapter.Fill(dt);
 
                Companies.DataSource = dt;
            }
        }
 
        protected void PendingCompanies_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            using (var dbm = new DBAppl())
            {
                SqlCommand command = new SqlCommand(@"SELECT ci.*, ri.firstName + ' ' + ri.lastName AS Reseller, oi.orderDate
                    FROM [td].[companyImport] ci
                    JOIN [td].[resellerInfo] ri ON ri.fImportId = ci.importId
                    JOIN [td].[orderItem] oi ON oi.fImportId = ci.importId
                    WHERE [status] = 'WAIT'", dbm.GetSqlConnection());
                SqlDataAdapter adapter = new SqlDataAdapter(command);
                DataTable dt = new DataTable();
                adapter.Fill(dt);
 
                PendingCompanies.DataSource = dt;
            }
        }
 
        void Authorize()
        {
            if (!ACL.HasAccess("CompanyDelete"))
                Companies.Columns.FindByUniqueName("DeleteColumn").Visible = false;
        }
    }
}


Regards,
m.
Milan
Top achievements
Rank 1
 answered on 14 Oct 2013
6 answers
533 views
Hello Community and telerik,

What properties do I have to set to get an "all day appointment"?

I want multiple appointments spanning the same time (00:00-24:00) to show up at the top of the day-view, in week-view and in month-view.

Thanks,
Gint
Plamen
Telerik team
 answered on 14 Oct 2013
3 answers
103 views
Hi,

When i set 
this.RadGrid1.ExportSettings.IgnorePaging = true;

the export works as expected, exporting all the data but the web control no longer pages on subsequent postbacks - it just shows all the records.  The initial postback is ok (posting back on the Export button click) but then, for instance if I click "next page" on the grid, paging is removed and all records are shown.

I need to ONLY affect the export, not the web control.  Incidentally, hiding columns results in the same behavior (columns are gone in subsequent postbacks), even though I re-show the columns during the _GridExporting event.  

Thanks,
JD

EDIT - BTW, I am using Advanced data binding.
Kostadin
Telerik team
 answered on 14 Oct 2013
10 answers
500 views
When I export my RadGrid to an ExcelML file, the date format isn't respected.  My dates are displayed via {0:MM/dd/yyyy}, but the entire instant shows up in my Excel file.

It looks like a cell format can be specified somehow...I've found the following class

   Telerik.Web.UI.GridExcelBuilder.NumberFormatType.ShortDate

but I can't figure out how to manually set cell formats.

Any thoughts?

Thanks!
Michelle

Kostadin
Telerik team
 answered on 14 Oct 2013
5 answers
165 views
Hi,
 I am investigating the replacement of the retired Microsoft OWC with a component with similar functionality. I have looked through the demos and I would like to verify that the following logic is achievable using the PivotGrid control.

Call the PivotGrid webpage passing a parameter of either a MS SQL database table or MS Analysis Services OLAP cube and programmatically bind to that dynamic data source.

If a default view has been previously created and saved in a SQL system table then that saved view is retrieved and the PivotGrid restored back Q: Using the Persistance.Framework demo functionality can the view layout be written into an SQL table?

If no default views exists, and the user is authorised to create views, then display an empty view of the data with all the drop areas (like the Fields List demo sample) to allow the user to construct their own view of the data. If the user is not authorised to create new views then the PivotGrid drop areas are all disabled and not displayed.

If other views exist in the system table then allow these to be selected from a dropdown list and the PivotGrid restored back.

Switch the displayed view between either the PivotGrid or a Chart based on the PivotGrid.

I think all this is achievable but I would like confirmation before downloading the 30 day trial and attempting a prototype ahead of purchasing.

Finally, could this be achieved using the Kendo UI as well as the ASP controls?

Thanks,

Paul.
Antonio Stoilkov
Telerik team
 answered on 14 Oct 2013
3 answers
101 views
I have a dashboard on one tab which loads some data from SQL if I close that tab and open a new tab which has a search screen, I still get a 'hit' on a debug point for that dashboard page ... so closing that dashboard tab does not actually stop processing and spending memory/resources for that page ?

Do we have some setting or property to prevent this behaviour ?
Aarsh
Top achievements
Rank 1
 answered on 14 Oct 2013
4 answers
108 views

I have telerik grid , which have some grid bound columns and one TextBoxTemplateColumn inside which i have hypenlink , when i am downloading the grid data ,all the data  is coming except the template column data , its coming as blank.

Can anyone please give code for that. Its urgent

Kostadin
Telerik team
 answered on 14 Oct 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?