Telerik Forums
UI for ASP.NET AJAX Forum
5 answers
494 views

I have a web application which needs to create a spreadsheet and save it to disk. Here's what I have so far:

Imports Telerik.Web.Spreadsheet

Dim wb As New Workbook
Dim ws As New Worksheet
Dim r As Row

wb.Sheets = New List(Of Worksheet) From {ws}
ws.Rows = New List(Of Row)

r = New Row With {.Cells = New List(Of Cell)}
r.Cells.Add(New Cell With {.Value = "Spreadsheet Title", .FontSize = Convert.ToInt16(Unit.Point(12).Value)})
ws.Rows.Add(r)

r = New Row With {.Cells = New List(Of Cell)}
r.Cells.Add(New Cell With {.Value = Today.ToShortDateString, .TextAlign = TextAlign.Left})
ws.Rows.Add(r)

r = New Row With {.Cells = New List(Of Cell)}
r.Cells.Add(New Cell With {.Value = "Column Header"})

<more column headers>

ws.Rows.Add(r)

For Each dr As DataRow In ds.Tables(0).Rows
     r = New Row With {.Cells = New List(Of Cell)}
     If Not IsDBNull(dr("Field1")) Then r.Cells.Add(New Cell With {.Value = dr("Field1")})

     <more fields>

Next dr

ws.Rows.Add(r)

Dim strPath As String = My.Settings.DocPath & "ExcelReports\"
Dim strFileName As String = "Filename.xlsx"

wb.Save(New FileStream(strPath + strFileName, FileMode.Create), ".xlsx")

Problem: When the code gets to the Save statement, I get this error: "nullable object must have a value".

I don't know what this means. The strPath, strFileName and wb objects all have values, so I don't know what nullable object is being referenced.

Can anyone point out what I'm doing wrong? Or am I going about this whole thing the wrong way (entirely possible, since this is my first attempt at this)?

Matthew
Top achievements
Rank 1
Veteran
 answered on 28 Mar 2021
1 answer
171 views

<INPUT onclick="javascript:setTimeout('window['Control_RadAjaxManager'].AsyncRequest(\'Control$ShareRadioButton\',\'\')', 0)" 

Code Snippet:
private void AddAjaxResponseScripts()
        {
            this.RadAjaxManager.ResponseScripts.Add("Sample.Controls.init(); if(Sample.QueryAddEdit) { Sample.AddEdit.init(); } ");
        }
Here Escape characters are not getting loaded properly .Missing  Escape characters in window['Control_RadAjaxManager'].
Current Version of Telerik 2015.3.1111.35 with .NetFramework 4.8.

Can anyone please help on this issue?

Rumen
Telerik team
 answered on 26 Mar 2021
2 answers
86 views

Hi, I am trying to provide visual indicators within the date input field of the data picker of possible errors with a date selection. I am trying to do this on keyboard input or the date picker date selection.

If the date selected or entered is before a date on the page, I want to show the error field in an error colour as that date could create program with other data being displayed. It is not a fatal error more a visual error. However, I do not see how this can be done because it appears that the date picker control is caching the initial classes and if you mouse over, that initial class over writes what is there and the visual error indication is lost. Alternately, if I try to set the inline styles with JQuery, they do not stick.

Basically, the concept is simple, put in a date before a displayed date, highlight the background of the input field. If the field is highlighted and you change the date to equal or be after the displayed, it goes back to the normal rendered state.

Am I basically SOL here?

Matt Smith
Top achievements
Rank 1
 answered on 25 Mar 2021
7 answers
1.1K+ views
I am trying to set certain rows on my grid in edit mode automatically on page load based on the content of one of the columns. I have seen some examples on this forum where either all rows are automatically put into edit mode during PreRender or by manually selecting multiple rows and firing a command event.

Please provide some examples on how certain rows can be automatically be put in edit mode during page load.
Doncho
Telerik team
 answered on 25 Mar 2021
6 answers
415 views

The viewstate or application's pages are already encrypted but looking at the Burp output of the response from a POST to the Telerik.UI.DialogHandler (ImageMananger) it seems the Telerik view state in the response appears not to be.

We've generated and specified the DialogParametersEncryptionKey, ConfigurationEncryptionKey, and ConfigurationHashKey keys in the site level web.config as described in article https://docs.telerik.com/devtools/aspnet-ajax/controls/editor/functionality/dialogs/security. This didn't change the viewstate.
The machine key in IIS is set for auto-generation.
I'm only assuming the Telerik viewstate can be encrypted because what I've read seems to imply that, but I haven't found a clear example so I'm not sure.

Dhaval
Top achievements
Rank 2
 answered on 25 Mar 2021
5 answers
777 views

i have excel file saved in SQL database as byte format, now i want to convert this bytes into excel and render it over RadSpreadsheet

 

Below is my code by getting exception "Value of type 'Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.Xlsx.XlsxFormatProvider' cannot be converted to 'Telerik.Web.UI.SpreadsheetProviderBase'"

Please help

01.Dim fileName As String = "Book1.xlsx"
02.Dim data() As Byte
03.Dim cmd As SqlCommand = New SqlCommand("select data from tblFiles")
04.data = GetData(cmd)
05. 
06.Dim memStream = New MemoryStream()
07.Dim binForm = New BinaryFormatter()
08.memStream.Write(data, 0, data.Length)
09.memStream.Seek(0, SeekOrigin.Begin)
10. 
11.Dim formatProvider As XlsxFormatProvider = New XlsxFormatProvider()
12.formatProvider.Import(memStream)
13.RadSpreadsheet1.Provider = formatProvider
Peter Milchev
Telerik team
 answered on 24 Mar 2021
11 answers
915 views

I have  a RadRadioButtonList on a ASP.Net page with 5 items in 3 columns.  With it set to 3 columns, the remaining 2 items go to another row which is what I would like to occur.  But what I am finding is that one of the remaining 2 items has text longer than the first item of the RadioButtonList which causes the columns to be misaligned.  Please see attached screenshot.  Note the column circled in red that is misaligned.

How do I get the columns to be aligned regardless of the length of the text?

Please help.  Thanks!

Sincerely,
Keith Jackson

Rumen
Telerik team
 answered on 24 Mar 2021
2 answers
184 views

Some of our users asked me if it is possible to format the html-code for better readability, some of the content was stored without newlines in the database and results in a pain to read in the html-mode when they need to make some minor changes. 

I'm not looking for something advanced more or less only some indentation and newlines.
Did not find anything useful when searching for this.. 

Alien Interactive AB
Top achievements
Rank 1
 answered on 24 Mar 2021
6 answers
126 views

Hi all, I have a strange problem that I hope will have a simple solution.

I have a RadGrid in an asp.net webform.  This grid shows a list of reports that can be downloaded.

I have created a RadButtonColumn and set its CommandName to GetReport.

I am checking the ItemCommand event for this name and it is firing.

However the routine I am using to retrieve the PDF is not displaying the file for download.

 

If I put the same routine into a generic .net button, it fires without issue and acts as is expected.

 

See attached form structure and code behind.

 

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FrmLotRegister.aspx.cs" Inherits="FrmLotRegister" Trace="false" EnableSessionState="False" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title></title>
    <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
        </Scripts>
    </telerik:RadScriptManager>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <div>
        <asp:SqlDataSource SelectCommand="SELECT DISTINCT Product, Binder, Date_Produced, Customer, Project, Location, Lot, Category, Job, Nata FROM View_Sample_Register WHERE (Nata > 0) AND (Product <> 'NULL')" ConnectionString="<%$ ConnectionStrings:TestConnectionString %>" ProviderName="System.Data.SqlClient" ID="DataSource1" runat="server" ></asp:SqlDataSource>
        <telerik:RadGrid ID="RadGrid1" runat="server" ShowGroupPanel="True" DataSourceID="DataSource1"
        AllowSorting="True" AllowPaging="True" AllowFiltering="True" AllowFilteringByColumn="True" EnableLinqExpressions="False" OnItemCommand="RadGrid1_ItemCommand" OnPreRender="RadGrid1_PreRender" Skin="Black" AllowAutomaticUpdates="True">
            <MasterTableView GroupLoadMode="server" ShowGroupFooter="True" GroupsDefaultExpanded="False" AutoGenerateColumns="False">
                <Columns>
                    <telerik:GridBoundColumn DataField="Date_Produced" DataType="System.DateTime" FilterControlAltText="Filter Date_Produced column" HeaderText="Date_Produced" SortExpression="Date_Produced" UniqueName="Date_Produced">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Project" FilterControlAltText="Filter Project column" HeaderText="Project" SortExpression="Project" UniqueName="Project">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Job" FilterControlAltText="Filter Job column" HeaderText="Job" SortExpression="Job" UniqueName="Job">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Lot" FilterControlAltText="Filter Lot column" HeaderText="Lot" SortExpression="Lot" UniqueName="Lot">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Location" FilterControlAltText="Filter Location column" HeaderText="Location" SortExpression="Location" UniqueName="Location">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Product" FilterControlAltText="Filter Product column" HeaderText="Product" SortExpression="Product" UniqueName="Product">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Binder" FilterControlAltText="Filter Binder column" HeaderText="Binder" SortExpression="Binder" UniqueName="Binder">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Customer" FilterControlAltText="Filter Customer column" HeaderText="Customer" SortExpression="Customer" UniqueName="Customer">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Category" FilterControlAltText="Filter Category column" HeaderText="Category" SortExpression="Category" UniqueName="Category">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Nata" DataType="System.Int32" FilterControlAltText="Filter Nata column" HeaderText="Nata" SortExpression="Nata" UniqueName="Nata">
                    </telerik:GridBoundColumn>
                    <telerik:GridButtonColumn ButtonType="PushButton" CommandName="GetReport" DataTextField="Nata" FilterControlAltText="Filter column column" HeaderText="Report" UniqueName="column" CommandArgument="GetReport">
                    </telerik:GridButtonColumn>
                </Columns>
                <GroupByExpressions>
                    <telerik:GridGroupByExpression>
                        <SelectFields>
                            <telerik:GridGroupByField FieldAlias="Job" FieldName="Job" FormatString="" HeaderText="" />
                        </SelectFields>
                        <GroupByFields>
                            <telerik:GridGroupByField FieldAlias="Job" FieldName="Job" FormatString="" HeaderText="" />
                        </GroupByFields>
                    </telerik:GridGroupByExpression>
                    <telerik:GridGroupByExpression>
                        <SelectFields>
                            <telerik:GridGroupByField FieldAlias="Lot" FieldName="Lot" FormatString="" HeaderText="" />
                        </SelectFields>
                        <GroupByFields>
                            <telerik:GridGroupByField FieldAlias="Lot" FieldName="Lot" FormatString="" HeaderText="" />
                        </GroupByFields>
                    </telerik:GridGroupByExpression>
                </GroupByExpressions>
            </MasterTableView>
<GroupingSettings CollapseAllTooltip="Collapse all groups"></GroupingSettings>
 
            <ClientSettings AllowDragToGroup="True">
            </ClientSettings>
        </telerik:RadGrid>
    </div>
        <p>
            <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
        </p>
    </form>
</body>
</html>

 

and the code behind

 

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
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;
using LabassistEngineerPortal.Data;
using System.Linq;
 
public partial class FrmLotRegister : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
 
    protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
        //On first run sort only to show the last month
        if (!Page.IsPostBack)
        {
            RadGrid1.MasterTableView.FilterExpression = "([Date_Produced] > '" + DateTime.Today.AddMonths(-1).ToShortDateString() + "') ";
 
            GridColumn column = RadGrid1.MasterTableView.GetColumnSafe("Date_Produced");
            column.CurrentFilterFunction = GridKnownFunction.GreaterThanOrEqualTo;
            column.CurrentFilterValue = DateTime.Today.AddMonths(-1).ToShortDateString();
            RadGrid1.GroupingEnabled = true;
            RadGrid1.MasterTableView.Rebind();
 
        }
 
 
    }
    //Take a Byte[] and turn it into a PDF for user download
    protected void Send_PDF(byte[] File, string Filename)
    {
        byte[] pdfdata = File;
        try
        {
            Response.Clear();
            Response.ContentType = "application/pdf";
 
            Response.BinaryWrite(pdfdata);
            string F = @"attachment;filename=""" + Filename + @"""";
            Response.AddHeader("content-disposition", F);
 
 
            Response.Cache.SetExpires(DateTime.Now.AddDays(7));
            Response.Cache.SetCacheability(HttpCacheability.Public);
            Response.Cache.SetValidUntilExpires(true);
             
            Response.End();
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
 
    //The same routine is used in the RadButtonColumn control.
    //The routine fires but will not send the PDF at the end
    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        //if button commandname is GetReport then fire this generic test function
        if (e.CommandName == "GetReport")
        {
            int? N = 4511;
            LabDatabase db = new LabDatabase();
            View_Sample_Register s = new View_Sample_Register();
            s = db.View_Sample_Register.FirstOrDefault(x => x.Nata == N);
            Nata_Reports r = new Nata_Reports();
            r = db.Nata_Reports.OrderByDescending(x => x.Revision).First(x => x.Nata_No.Value == N);
            string filename = s.Date_Produced.Value.Day + "-" + s.Date_Produced.Value.Month + "-" + s.Date_Produced.Value.Year + " " + s.Product + "-" + s.Binder + " " + s.Category + " " + r.Nata_No + ".pdf";
 
            Send_PDF(r.Report, filename);
 
        }
    }
 
    //when traditional .net button is used this routine works fine.
    protected void Button1_Click(object sender, EventArgs e)
    {
        int? N = 4511;
        LabDatabase db = new LabDatabase();
        View_Sample_Register s = new View_Sample_Register();
        s = db.View_Sample_Register.FirstOrDefault(x => x.Nata == N);
        Nata_Reports r = new Nata_Reports();
        r = db.Nata_Reports.OrderByDescending(x => x.Revision).First(x => x.Nata_No.Value == N);
        string filename = s.Date_Produced.Value.Day + "-" + s.Date_Produced.Value.Month + "-" + s.Date_Produced.Value.Year + " " + s.Product + "-" + s.Binder + " " + s.Category + " " + r.Nata_No + ".pdf";
 
        Send_PDF(r.Report, filename);
    }
}

 

What am I doing wrong here?  Why can I not seem to retrieve a file using the Gridviews buttonColumn?

 

kieran
Top achievements
Rank 2
 answered on 24 Mar 2021
2 answers
7.8K+ views

Hello,

I have a legacy .NET web forms application with targetFramework 4.6.2.

I need to install Telerik.Web.UI  and Telerik.Web.UI.Skims.dll for this application. Please direct me from what location should I download the dll. I looked in Nuget but unable to find the dll

 

Thanks

Kapil 

Doncho
Telerik team
 answered on 23 Mar 2021
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?