This is a migrated thread and some comments may be shown as answers.

Edit Form Validation

7 Answers 425 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shehab
Top achievements
Rank 1
Shehab asked on 11 Jul 2008, 02:19 PM
Hello,
I couldn't find a way to validate text boxes in the EditFrom in RadGrid. Any direction will be helpful.
Thanks,
Shehab

7 Answers, 1 is accepted

Sort by
0
Gary
Top achievements
Rank 1
answered on 11 Jul 2008, 02:28 PM
Hi Shehab.
I am trying to do the same thing.  There's a link to show examples, but I can't get to work.  Let me know if you can...

http://www.telerik.com/help/aspnet/grid/grdvalidation.html 
0
Accepted
Vlad
Telerik team
answered on 11 Jul 2008, 02:52 PM
Hi guys,

Here is the validation example:
http://www.telerik.com/DEMOS/ASPNET/Prometheus/Grid/Examples/DataEditing/Validation/DefaultCS.aspx

Greetings,
Vlad
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Gary
Top achievements
Rank 1
answered on 11 Jul 2008, 04:21 PM
This does not work for me.  Is there some property of the grid or something of that nature that will prevent the error message from displaying?  It does validate, but onlt on postback (still no message though).  I have two grids on the page.  The first one allows the user to select a row, when they do, I populate the grid below based on the user's selection and make it visible.  Any ideas?  Thanks

Gary
0
Shehab
Top achievements
Rank 1
answered on 11 Jul 2008, 05:01 PM
Hi Gary,
It worked for me, all you have to do is to create a GridTempleteColumn and creat a lable to view the data inside the ItemTeplate tags then create the EditItemTemplate with the textbox and the RequiredFieldValidator no code is required. Here is my aspx that worked, hope it helps you.
                <radG:GridTemplateColumn HeaderText="FaxDep" SortExpression="FaxDep" UniqueName="TemplateColumn">  
                        <HeaderStyle Width="80px" /> 
                        <ItemTemplate> 
                            <asp:Label runat="server" ID="lblFaxDep" Text='<%# Eval("FaxDep") %>'></asp:Label> 
                        </ItemTemplate> 
                        <EditItemTemplate> 
                            <asp:TextBox runat="server" ID="tbFaxDep" Text='<%# Bind("FaxDep") %>'></asp:TextBox><span style="color: Red">*</span> 
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="tbFaxDep"   
                            ErrorMessage="This field is required" runat="server">  
                            </asp:RequiredFieldValidator> 
                        </EditItemTemplate> 
                </radG:GridTemplateColumn> 
 
Thanks,
Shehab
0
Gary
Top achievements
Rank 1
answered on 11 Jul 2008, 05:13 PM
Thanks for the reply and code.  My grid html looks like this, but no message displays, here's the grid, for sake of brevity, I removed other columns:

<telerik:RadGrid ID="RadGridCageCode" runat="server" AllowFilteringByColumn="False"AllowPaging="True" AllowSorting="True" GridLines="None" Skin="Vista" EnableAJAX="true" width="80%" Height="300px" DataSourceID="ObjectDataSourceCageCode" PagerStyle-Mode="NextPrevNumericAndAdvanced" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" OnInit="RadGridCageCodeLookup_Init" OnItemCommand="RadGridCageCodeLookup_ItemCommand"
OnInsertCommand="RadGridCageCodeLookup_InsertCommand"
OnItemInserted="RadGridCageCodeLookup_ItemInserted"
OnDeleteCommand="RadGridCageCodeLookup_DeleteCommand" OnItemDeleted="RadGridCageCodeLookup_ItemDeleted" OnUpdateCommand="RadGridCageCodeLookup_UpdateCommand" OnItemUpdated="RadGridCageCodeLookup_ItemUpdated"
OnItemCreated="RadGridCageCodeLookup_ItemCreated"
OnColumnCreated="RadGridCageCodeLookup_ColumnCreated" OnItemDataBound="RadGridCageCodeLookup_ItemDataBound" >

<ClientSettings >
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
<Selecting AllowRowSelect="false" />
<ClientEvents />
</ClientSettings>

<PagerStyle Mode="NextPrevNumericAndAdvanced"></PagerStyle>

<MasterTableView AllowMultiColumnSorting="True" PageSize="5" CommandItemDisplay="TopAndBottom" AutoGenerateColumns="False" DataKeyNames="CageCodeID" DataSourceID="ObjectDataSourceCageCode">

<RowIndicatorColumn Visible="False">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn Visible="False" Resizable="False">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>

<Columns>
<telerik:GridEditCommandColumn ButtonType="ImageButton" UpdateImageUrl="~\RadControls\Skins\Vista\Grid\Update.gif" EditImageUrl="~\RadControls\Skins\Vista\Grid\Edit.gif" InsertImageUrl="~\RadControls\Skins\Vista\Grid\AddRecord.gif" CancelImageUrl="~\RadControls\Skins\Vista\Grid\Cancel.gif"
UniqueName="EditCommandColumn">
</telerik:GridEditCommandColumn>

<telerik:GridBoundColumn DataField="CageCodeID" DataType="System.Int32" HeaderText="CageCodeID" ReadOnly="True" SortExpression="ID" UniqueName="CageCodeID" Visible="false">
</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="ManufacturerID" DataType="System.Int32" HeaderText="Mfg ID" SortExpression="ManufacturerID" UniqueName="ManufacturerID" visible="false" >
</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="CageCode" HeaderText="Cage Code" SortExpression="CageCode" UniqueName="CageCode" >
</telerik:GridBoundColumn>

<telerik:GridTemplateColumn HeaderText="Address" SortExpression="Address" UniqueName="Addresstemplate" >
<ItemTemplate>
     
<asp:Label runat="server" ID="lblAddress" Text='<%# Eval("Address") %>' />
</ItemTemplate>
<EditItemTemplate>
     
<asp:TextBox runat="server" ID="tbAddress" Text='<%# Bind("Address") %>'
/>
     
<span style="color: Red">*</span><asp:RequiredFieldValidator ID="rvalAddress" ControlToValidate="tbAddress" ErrorMessage="Address is required!" runat="server"></asp:RequiredFieldValidator
>
</EditItemTemplate
>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="Address2" HeaderText="Address 2" SortExpression="Address2" UniqueName="Address2" ConvertEmptyStringToNull="false" >
</telerik:GridBoundColumn>

<telerik:GridButtonColumn ConfirmText="Are you sure you want to delete this record?" ButtonType="ImageButton" ImageUrl="~\RadControls\Skins\Vista\Grid\Delete.gif" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
<HeaderStyle Width="20px" />
</telerik:GridButtonColumn>

</Columns>
</MasterTableView>
</telerik:RadGrid>

Gary

0
Gary
Top achievements
Rank 1
answered on 11 Jul 2008, 05:13 PM

0
Gary
Top achievements
Rank 1
answered on 11 Jul 2008, 05:13 PM

Tags
Grid
Asked by
Shehab
Top achievements
Rank 1
Answers by
Gary
Top achievements
Rank 1
Vlad
Telerik team
Shehab
Top achievements
Rank 1
Share this question
or