Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
286 views

Dear All,

 

i am trying to create form as amount inputter, using RadNumericText and CompareValidator (to compare min max value between RadNumeric) through code behind. CompareValidator work perfectly where value of RadNumeric doesn't contain digit behind commas (attached images : data no 1), but, when i'm inputted value with commas, it's doesn't working as expected, as shown in the attached images.

No         City               Min                     Max

1            Aceh             $ 100.001,00      $ 100.000,00

                                                               *Amount min cannot be greater than amount max

2.           Yogya           $ 100.000,00      $ 100.000,00

 

3.           Banten         $ 100.000,88      $ 100.000,99

                                                             *Amount min cannot be greater than amount max

 

From data above, no 1, CompareValidator working perfectly, but not for data no 3, where value has any digit behind commas. Any advice how to compare min max value with commas at data no 3 ?

 

Regard,

 

Ragil

 

protected RadNumericTextBox mytextbox;
 
public void InstantiateIn(System.Web.UI.Control container)
{
    mytextbox = new RadNumericTextBox();
    mytextbox.AutoPostBack = false;
    mytextbox.ID = rankName + typeName + "MyTextBox";
    mytextbox.NumberFormat.DecimalDigits = 2;
    mytextbox.NumberFormat.GroupSeparator = ".";
    mytextbox.NumberFormat.DecimalSeparator = ",";
    mytextbox.Type = NumericType.Currency;
    //mytextbox.DataType = "System.Decimal";
 
    reqValid = new RequiredFieldValidator();
    reqValid.ForeColor = System.Drawing.Color.Red;
    reqValid.ErrorMessage = "* Required field";
    reqValid.CssClass = "has-error";
    reqValid.ControlToValidate = rankName + typeName + "MyTextBox";
    reqValid.Display = ValidatorDisplay.Dynamic;
 
    if (typeName == "Max")
    {
        compValid = new CompareValidator();
        compValid.ForeColor = System.Drawing.Color.Red;
        compValid.ErrorMessage = "* Amount Min can not be greater than Amount Max";
        compValid.CssClass = "has-error";
        compValid.Display = ValidatorDisplay.Dynamic;
 
        compValid.ControlToValidate = rankName + "Max" + "MyTextBox";
        compValid.ControlToCompare = rankName + "Min" + "MyTextBox";
        compValid.Operator = ValidationCompareOperator.GreaterThanEqual;
        compValid.Type = ValidationDataType.Currency;
        compValid.ValidationGroup = "ValidateAmount";
 
    }
 
    container.Controls.Add(mytextbox);
    container.Controls.Add(reqValid);
 
    if (typeName == "Max")
    {
        container.Controls.Add(compValid);
    }
}
Attila Antal
Telerik team
 answered on 23 Jan 2020
5 answers
646 views

Hello,

I have a radcombobox, and when I disable it, I can still enter text in the textbox. How can I also disable the textbox so no text can be enter when my combobox is desabled ?

Thanx for your help.

Rumen
Telerik team
 answered on 23 Jan 2020
4 answers
481 views
I have the following Grid on a form:

    <telerik:RadGrid ID="rgd_TaskPermissions" runat="server"  GridLines="None" AutoGenerateColumns="False" Width="320px">
    <MasterTableView>
        <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
        <RowIndicatorColumn>
        <HeaderStyle Width="20px"></HeaderStyle>
        </RowIndicatorColumn>
        <ExpandCollapseColumn>
        <HeaderStyle Width="20px"></HeaderStyle>
        </ExpandCollapseColumn>
            <Columns>
                <telerik:GridBoundColumn DataField="Object" HeaderText="Table" 
                    SortExpression="Object" UniqueName="Object" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
                </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Select" HeaderText="Select" 
                    SortExpression="Select" UniqueName="Select" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
                </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Update" HeaderText="Update" 
                    SortExpression="Update" UniqueName="Update" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
                </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Insert" HeaderText="Insert" 
                    SortExpression="Insert" UniqueName="Insert" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Delete" HeaderText="Delete" 
                    SortExpression="Delete" UniqueName="Delete" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
                </telerik:GridBoundColumn>
                <telerik:GridTemplateColumn UniqueName="TemplateColumn">
                    <ItemTemplate> 
                    <asp:Button ID="btn_ModifyPerms" runat="server" Text="Modify"  />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
    </MasterTableView>
</telerik:RadGrid>

I fill the grid by calling a Stored Procedure in SQL

Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
    Label1.Text = Session("Object")
    rgd_TaskPermissions.DataSource = GetPermissions()
    rgd_TaskPermissions.DataBind()
End Sub
Private Function GetPermissions() As DataTable
    Dim Table As String = Session("Object")
    Dim DatabaseName As String = Session("DBName")
    Dim Grantee As String = Session("TaskRole")
    Dim connectionString = New SqlConnection("server=DO-IT-AB\MSSQLAB;database=AeriesAdmin;UID=XXX;PWD=XXX;")
    Dim command = New SqlCommand("aa_task_table_permissions_by_object", connectionString)
    command.CommandType = CommandType.StoredProcedure
    command.Parameters.Add("@DBName", SqlDbType.VarChar).Value = DatabaseName
    command.Parameters.Add("@Grantee", SqlDbType.VarChar).Value = Grantee
    command.Parameters.Add("@Table", SqlDbType.VarChar).Value = Table
    command.Connection.Open()
    Dim myDataAdapter As New SqlDataAdapter(command)
    Dim myDataSet As New DataSet
    Dim dtData As New DataTable
    myDataAdapter.Fill(myDataSet)
    Return myDataSet.Tables(0)
    command.Connection.Close()
End Function

SP

USE [AeriesAdmin]
GO
  
SET ANSI_NULLS ON
GO
  
SET QUOTED_IDENTIFIER ON
GO
  
CREATE PROCEDURE [dbo].[aa_task_table_permissions_by_object] 
  
@dbname sysname, 
@Grantee varchar(25),
@Table varchar(25)
    
AS 
BEGIN 
  
IF OBJECT_ID('tempdb..#tmpResults') IS NOT NULL 
DROP TABLE #tmpResults 
   
CREATE TABLE #tmpResults 
( 
[Owner] NVARCHAR(MAX), 
[Object] NVARCHAR(MAX), 
[Grantee] NVARCHAR(MAX), 
[Grantor] NVARCHAR(MAX),  
[ProtectType] NVARCHAR(MAX), 
[Action] NVARCHAR(MAX), 
[Column] NVARCHAR(MAX) 
) 
   
DECLARE @sp_executesql nvarchar(1024) 
   
SELECT @sp_executesql = @dbname + '.sys.sp_executesql' 
   
INSERT INTO #tmpResults 
( 
[Owner], 
[Object], 
[Grantee], 
[Grantor], 
[ProtectType], 
[Action], 
[Column] 
) 
EXECUTE @sp_ExecuteSQL N'sp_Helprotect' 
   
;with cte as (select Object, Grantee, Action,  
row_number() over (partition by Object, Grantee  ORDER BY Action) as Row from #TmpResults) 
   
select Object, Grantee, max(case when Action = 'Delete' then char(88) end) as [Delete],
  
max(case when Action = 'Insert' then char(88) end) as [Insert],
  
max(case when Action = 'Select' then char(88) end) as [Select],
  
max(case when Action = 'Update' then char(88) end) as [Update]
  
from #TmpResults
  
  
WHERE Grantee = @Grantee AND [Object] LIKE @Table
  
GROUP by Object, Grantee
  
END
  
GO

This all works great. However, I would like to extend this somewhat in that rather than just displaying the letter X in the row of the grid for each column, I would like to display a checkbox that is either checked or unched depending on the value in the cell. Is there a way to accomplish this, and if so, would it be possible to see an example?

Thank you in advance.










Rumen
Telerik team
 answered on 23 Jan 2020
4 answers
645 views

ASPX:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TelerikUpload.aspx.cs" Inherits="ImportMPV2_WebTest.TelerikUpload" %>
 
<!DOCTYPE html>
 
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
        <div>
            <telerik:RadAsyncUpload
                AllowedFileExtensions="xlsx"
                EnableInlineProgress="true"
                ID="RadAsyncUpload1"
                MaxFileInputsCount="1"
                MultipleFileSelection="Disabled"
                OnFileUploaded="RadAsyncUpload1_FileUploaded"
                RenderMode="Lightweight"
                runat="server"
                Skin="Telerik"
                TargetDir="Uploads">
                <FileFilters>
                    <telerik:FileFilter Description="Excel Files(xlsx)" Extensions="xlsx" />
                </FileFilters>
            </telerik:RadAsyncUpload>
        </div>
        <br />
        <telerik:RadButton AutoPostBack="true" runat="server" Text="Import" Skin="Telerik" />
    </form>
 
    <pre>
<asp:label id="lblUploadResults" runat="server"></asp:label>
    </pre>
    <pre>
<asp:label id="lblSSISResults" runat="server"></asp:label>
    </pre>
 
</body>
</html>

 

Code behind:

protected void RadAsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e)
{
    UploadedFile uploadFile = e.File;
    string xlFilePath = Path.Combine(Server.MapPath(WebConfigurationManager.AppSettings["uploadDir"]), uploadFile.FileName);
 
    // Display upload results
    lblUploadResults.Text = "File Uploaded\n"
        + "File name: " + uploadFile.FileName + "\n"
        + "Content type: " + uploadFile.ContentType + "\n"
        + "Content length: " + uploadFile.ContentLength + "\n"
        + "Last modified date: " + uploadFile.LastModifiedDate + "\n";
 
    // Execute SSIS package
    SSISExecutor ssisExecutor = new SSISExecutor(
        xlFilePath
        , "Balance Import"
        , "gregorym"
        , false
        , WebConfigurationManager.AppSettings["logFilePath"]
        , WebConfigurationManager.ConnectionStrings["DatabasePEP1"].ConnectionString
        );
    ssisExecutor.Exec(out List<string> resultList);
 
    // Display SSIS results
    string s = "SSIS results:\n" + xlFilePath + ":\n\n";
    foreach (string result in resultList)
    {
        s += result + "\n";
    }
    lblSSISResults.Text = s;
}

 

Output:

File Uploaded
File name: ImportV2_Sample.xlsx
Content type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Content length: 326210
Last modified date: 1/13/2020 4:47:40 PM
 
     
SSIS results:
C:\ImportMPV2_WebTest\Uploads\ImportV2_Sample.xlsx:
 
Error: File "C:\ImportMPV2_WebTest\Uploads\ImportV2_Sample.xlsx" not found

 

 

 

 

Matt
Top achievements
Rank 1
Veteran
 answered on 22 Jan 2020
3 answers
181 views

Hoping somebody can help me here.  I am following an example posted by Telerik on how to do this in this forum.  I am getting "" returned as the value for every column value (.Text).  All of my grid columns are GridtTmplateColumns and the column values are labels within the template.

 

How do accomplish this with GridTemplateColumns?  I have been struggling with this for the entire day.  Can I somehow use item.findcontrol here?

 

            Dim dtRecs As DataTable = New DataTable

            For Each col As GridColumn In rgbt.Columns
                If (col.ColumnType = "GridTemplateColumn") Then
                    Dim colstring As String
                    colstring = col.UniqueName
                    dtRecs.Columns.Add(colstring)
                End If
            Next

            For Each item As GridDataItem In rgbt.Items
                Dim newRow As DataRow = dtRecs.NewRow()
                For Each column As GridColumn In rgbt.Columns
                    If (column.ColumnType = "GridTemplateColumn") Then
                        newRow(column.UniqueName) = item.(column.UniqueName).Text    'RETURNS ""
                        dtRecs.Rows.Add(newRow)
                    End If
                Next
            Next

 

Thanks!

Acadia
Top achievements
Rank 1
Iron
 answered on 22 Jan 2020
1 answer
358 views

Hi,

 

I get an error [HttpException (0x80004005): Cannot use a leading .. to exit above the top directory.]

with:

    <telerik:radButton ButtonType="LinkButton" NavigateUrl="~/shop/shoppingcart.aspx" id="btn_nextsteptop" runat="server"><ContentTemplate>
        <asp:Literal ID="Literal1" Text="Jippeee" runat="server"></asp:Literal></ContentTemplate></telerik:radButton>

 

When I remove the tilde then the error is not occuring, so probably the relative path functionality is broken here?

 

Marc

Peter Milchev
Telerik team
 answered on 22 Jan 2020
1 answer
719 views

hi , i am using rad window to display content, i need to change color of the rad window from gray to white color

screenshot : http://prntscr.com/qr3k2i

Thanks

Rumen
Telerik team
 answered on 22 Jan 2020
1 answer
263 views
Hi,
    In Asp.net ReportViewer got predefined skins ? like, slik,bootstrap,office 2010 Black, office 2010 Blue or from Theme builder can create custom skins ?.


Thanks
Rumen
Telerik team
 answered on 22 Jan 2020
1 answer
175 views

I have several RadGrids nested within their own ASP.NET UpdatePanels which are within an ASP.NET MultiView. I'm experiencing issues when it comes to exporting the RadGrid to Excel.

 

I know that the control needs to be registered to allow a PostBack, but I want to specifically register the in-built ExportToExcel button. In the ItemCreated event, I was able to identify GridCommandItems and register them as PostBackControls, but this is also registering the "Add New Record" button, causing a PostBack to occur if they click the "Add New Record" button.

 

Is there any way to programmatically identify JUST the "Export to Excel" Command Item?

Chris
Top achievements
Rank 1
 answered on 21 Jan 2020
6 answers
471 views
Scenario / Requirements:

I want to have a grid that looks and behaves almost exactly like excel.  Try to remember this key point.

I want to be able to move around in the grid with my arrow keys (Ignore, I have read the various posts on this)
I want to be able to edit any cell that currently has focus.  No, I don't want to click an Edit button first.  If I am in the cell and hit a key, I am editing the cell.

MOST IMPORTANT:
**After** I edit a cell, I need to do a partial postback to the server, where I will recalculate several other cells(columns) in the datasource bound to this control, using the updated value in the calling cell.  (The caluclations are performed on the server). Then, after the calculations are complete, I want the cell's row to update with the new values in the underlying dataset.   ***AND**, surprisingly, I don't want to lose focus of the control that received it after I updated the first cell.

As far as I know, I have looked at all of the examples on your website, so I think this scenario extends a bit beyond the standard examples.

So, is this possible with RadGrid, and if so, could you give me a few hints of how to do it?
Attila Antal
Telerik team
 answered on 21 Jan 2020
Narrow your results
Selected tags
Tags
+? more
Top users last month
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Dean
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Emil
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Dean
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Emil
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?