Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
313 views
I have a rad grid that generates columns and the edit function from a database. I have figured out how to make sure an input field is not blank in the code behind. What I want to do is be able to check to see if the textbox input is an integer within the edit columns. I don't really know anything about rad grids yet, I just pieced together things from the tutorials. How would I validate to make sure it is a number? Here is my aspx file
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="RadGrid.aspx.vb" Inherits="RadGrid" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="ScriptManager1" runat="server"
        EnableTheming="True">
    </telerik:RadScriptManager>
    <br />
    <telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticDeletes="True"
        AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowPaging="True"
        DataSourceID="SqlDataSource1" GridLines="None">
<MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" DataKeyNames="id"
            DataSourceID="SqlDataSource1">
    <Columns>
        <telerik:GridEditCommandColumn>
        </telerik:GridEditCommandColumn>
        <telerik:GridBoundColumn DataField="id" DataType="System.Int32" HeaderText="id"
            ReadOnly="True" SortExpression="id" UniqueName="id">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="title" HeaderText="title"
            SortExpression="title" UniqueName="title">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="description" HeaderText="description"
            SortExpression="description" UniqueName="description">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="price" DataType="System.Int32"
            HeaderText="price" SortExpression="price" UniqueName="price">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="quantity" DataType="System.Int32"
            HeaderText="quantity" SortExpression="quantity" UniqueName="quantity">
        </telerik:GridBoundColumn>
    </Columns>
    <EditFormSettings>
        <EditColumn UniqueName="EditCommandColumn1">
        </EditColumn>
    </EditFormSettings>
</MasterTableView>
    </telerik:RadGrid>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConflictDetection="CompareAllValues"
        ConnectionString="<%$ ConnectionStrings:TestDevConnectionString %>"
        DeleteCommand="DELETE FROM [Data] WHERE [id] = @original_id AND (([title] = @original_title) OR ([title] IS NULL AND @original_title IS NULL)) AND (([description] = @original_description) OR ([description] IS NULL AND @original_description IS NULL)) AND (([price] = @original_price) OR ([price] IS NULL AND @original_price IS NULL)) AND (([quantity] = @original_quantity) OR ([quantity] IS NULL AND @original_quantity IS NULL))"
        InsertCommand="INSERT INTO [Data] ([title], [description], [price], [quantity]) VALUES (@title, @description, @price, @quantity)"
        OldValuesParameterFormatString="original_{0}"
        SelectCommand="SELECT * FROM [Data]"
        UpdateCommand="UPDATE [Data] SET [title] = @title, [description] = @description, [price] = @price, [quantity] = @quantity WHERE [id] = @original_id AND (([title] = @original_title) OR ([title] IS NULL AND @original_title IS NULL)) AND (([description] = @original_description) OR ([description] IS NULL AND @original_description IS NULL)) AND (([price] = @original_price) OR ([price] IS NULL AND @original_price IS NULL)) AND (([quantity] = @original_quantity) OR ([quantity] IS NULL AND @original_quantity IS NULL))">
        <DeleteParameters>
            <asp:Parameter Name="original_id" Type="Int32" />
            <asp:Parameter Name="original_title" Type="String" />
            <asp:Parameter Name="original_description" Type="String" />
            <asp:Parameter Name="original_price" Type="Int32" />
            <asp:Parameter Name="original_quantity" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="title" Type="String" />
            <asp:Parameter Name="description" Type="String" />
            <asp:Parameter Name="price" Type="Int32" />
            <asp:Parameter Name="quantity" Type="Int32" />
            <asp:Parameter Name="original_id" Type="Int32" />
            <asp:Parameter Name="original_title" Type="String" />
            <asp:Parameter Name="original_description" Type="String" />
            <asp:Parameter Name="original_price" Type="Int32" />
            <asp:Parameter Name="original_quantity" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="title" Type="String" />
            <asp:Parameter Name="description" Type="String" />
            <asp:Parameter Name="price" Type="Int32" />
            <asp:Parameter Name="quantity" Type="Int32" />
        </InsertParameters>
    </asp:SqlDataSource>
    <telerik:RadAjaxManager runat="server" EnableHistory="True">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    </form>
</body>
</html>

Here is my vb file
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports Telerik.Web.UI
Partial Class RadGrid
    Inherits System.Web.UI.Page

   

    Protected Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated
        'check out the function in utilities for the textbox requirement validation
        Utilities.radValidateText(e, "title", "TitleRequired", "Title is required")
        Utilities.radValidateText(e, "description", "DescRequired", "Description is required")

    End Sub
End Class

And here is the function in my utilities class

    'this function takes in an object from a radgrid
    'the column name and a unique id for the validation name
    'it then makes sure that there is text within a textbox
    Public Shared Function radValidateText(ByVal e As Object, ByVal columnName As String, ByVal validatorID As String, ByVal errorMsg As String)

        
        If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then
            Dim item As GridEditableItem = TryCast(e.Item, GridEditableItem)
        
            Dim editor As GridTextBoxColumnEditor = DirectCast(item.EditManager.GetColumnEditor(columnName), GridTextBoxColumnEditor)
        
            Dim cell As TableCell = DirectCast(Editor.TextBoxControl.Parent, TableCell)

            Dim validator As New RequiredFieldValidator()

            editor.TextBoxControl.ID = validatorID

            validator.ControlToValidate = editor.TextBoxControl.ID
            validator.ErrorMessage = errorMsg
            cell.Controls.Add(validator)
        End If

    End Function 'radValidateText
Basically, I need a similar function to say "this column must be an number" if they enter letters. Thanks in advance,





Rosen
Telerik team
 answered on 09 Jun 2009
1 answer
153 views

I have a GripTemplateColumn which I dynamically (onItemDatabound) creating Checkbox, ComboBox, TextBox depending on the type of the data. I want to do update by having an update link/button next to the control column and do update. Can someone give me suggestion to implement it?

Here is the .aspx code I am using

<telerik:GridTemplateColumn HeaderText="Value" HeaderStyle-Width="40%">
                    <ItemTemplate>                  
                    <telerik:RadTextBox ID="txtBoxValue" runat="server" Visible="false"></telerik:RadTextBox>
                    <telerik:RadNumericTextBox ID="numericTxtBoxValue" runat="server" Visible="false"></telerik:RadNumericTextBox>
                    <telerik:RadComboBox ID="dropDownValue" runat="server" Visible="false">
                        <Items>       <telerik:RadComboBoxItem id="Item1" runat="server"></telerik:RadComboBoxItem>
      </Items>
                    </telerik:RadComboBox>
                    <asp:CheckBox ID="chkBox" runat="server" Visible="false"></asp:CheckBox>                   
                    </ItemTemplate>

Here is the code how I populate the checkbox and other controls in the Grid ItemDataBound

CheckBox chkBoxValue = e.Item.FindControl("chkBox") as CheckBox;
                        chkBoxValue.ID = "chkValue";
                        if (value == "1" || value == "True")
                            chkBoxValue.Checked = true;
                        else
                            chkBoxValue.Checked = false;
                        chkBoxValue.Visible = true;

Here is the code for Update Link columm :

                    <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Update" Text="Update"
                        UniqueName="UpdateColumn">
                        <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                    </telerik:GridButtonColumn>

But I could not get the updated value of the controls inside the UpdateCommand method of the code behind.

I checked the onle demo and help but all of them are using the inline edit or some sort of built in edit mode to edit all the columns of the row. In my case I just need to update only one column and it is already displayed in a editable form i.e in textbox, combobox etc. I just need to click the Update button for each row and save the edited value.

Any suggestion is appreciated!
 

Veli
Telerik team
 answered on 09 Jun 2009
0 answers
103 views

Hi expert,

           I am using telerik:RadPanelBar. the RadPanelItem is binding at runtime. It is working fine in IE.
But when I am browsing in 'Mozilla Firefox' or in 'Google Chrome' getting following error "Assertion Failed: Length of elements and json must be the same! "

Could you please help out how to solve this problem.

Thanks & regards,
Pravat Sharma

Pravat
Top achievements
Rank 1
 asked on 09 Jun 2009
1 answer
175 views
In a financial system that I am creating I have a list of invoices in a Telerik RadGrid.  one of the requirements of the application is the ability to void an invoice if there is some flaw with it.  What I have done is to include the void button on the grid listing all of the invoices for a receivable.  I would like to have a RadPrompt window pop up when a user clicks on the void button to provide a reason for voiding the invoice, with the ability to cancel out of the process at that point.  Is this possible?
Veli
Telerik team
 answered on 09 Jun 2009
2 answers
246 views
Is there a way to remove the border lines when exporting a grid to PDF?
Daniel
Telerik team
 answered on 09 Jun 2009
1 answer
278 views
Hello,
I am not sure how to accomplish this.  I have a numeric control on a form with spin buttons.  I want to block the users from entering value directly into the text box and force them to only use the spin buttons.  I tried setting read only to true but that also disabled the spin buttons.
Thanks in advanced

John
Princy
Top achievements
Rank 2
 answered on 09 Jun 2009
3 answers
196 views
Hello,
I am trying to set the mask using java script but i am not able to do it

Here is my code

case "4###############":
            masks = [
                        new Telerik.Web.UI.RadLiteralMaskPart('4'),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart()
                     ];
            text._length = 0;
            text._setMask(masks);
            text.set_value('');
             break;
         case "<51..55>#############":
             masks = [
                        new Telerik.Web.UI.RadNumericRangeMaskPart(51, 55, false, true),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart()
                      ];
             text._length = 0;
             text._setMask(masks);
             text.set_value('');
            break;
        case "<34|37>#############":
            var Values = new Array(34,37);
            masks = [
                        new Telerik.Web.UI.RadEnumerationMaskPart(Values),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart()
                      ];
            text._length = 0;
            text._setMask(masks);
            text.set_value('');
            break;
        case "<3|1800|2131>##############":
            masks = [
                        new Telerik.Web.UI.RadLiteralMaskPart('<3|1800|2131>'),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart()
                      ];
            text._length = 0;
            text._setMask(masks);
            text.set_value('');
            break;
        case "<300|301|302|303|304|305|36|38>############":
            break;
        case "6011############":
                masks = [
                        new Telerik.Web.UI.RadLiteralMaskPart('6011'),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart(),
                        new Telerik.Web.UI.RadDigitMaskPart()
                     ];
                text._length = 0;
                text._setMask(masks);
                text.set_value('');
                break;
                default:
                    text._length = 0;
                    text.set_value('');
                break;


Am not able to create mask for <34|37>############# and not able to input values in text box

Thanks & regards
Mahesh
Mahesh
Top achievements
Rank 1
 answered on 09 Jun 2009
1 answer
111 views
I am trying to implement a RadCombobox that has multiple columns loaded on the fly from a page method after filtering based on what the user is typing:

ID | Name | Address | City | Province

When a user selects a row I want to populate the selected item with the format "ID - Name" and set the selected value to the ID field.  I am thinking that I need to do this with the OnSelectedIndexChanged event.  The data set in the tens of thousands of rows.  Is that the best method to change the text of the selected item?

Thanks,
Colin
Shinu
Top achievements
Rank 2
 answered on 09 Jun 2009
4 answers
144 views
Hi

I can not find Wikiplus column type( for rich text editing ) in the column listing for sharepoint document library. Interestingly, this option is available for sharepoint Lists. Is there any way i can associte this column type to sharepoint document library also?

thanks
akshay
Stanimir
Telerik team
 answered on 09 Jun 2009
1 answer
90 views
Hello!

I'm binding a standard dropdownlist to an objectdatasource by setting the properties "datatextfield" and "datavaluefield".

When I load a record from my database, I want to show the selected value which was saved into the record. I do this by setting dropdownlist1.text = valuefromtherecord while Page_Load-Event.

After Page is loaded, I can see the saved value selected in the dropdownlist.


When I want to do the same with RadComboBox, the control stays blank after Page-Loading!?! Why?

Any suggestions?

Bye

Michael
Shinu
Top achievements
Rank 2
 answered on 09 Jun 2009
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?