Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 26th, 2006, 01:14 PM
Authorized User
 
Join Date: Apr 2006
Posts: 79
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via AIM to anujrathi Send a message via MSN to anujrathi Send a message via Yahoo to anujrathi
Default Validation controls in datalist

Hi friends,

I m using a DataList to show the details of any employees. & provide EditItemTemplate to edit the personal information. There are some textbox & drop downs. Now how can I use Validation Controls for these IditTempalte controls. I have placed Required field validator with these controls, but it does'nt work.
Pls solve my problem.

How can I use Validation controls in a DataList when I m editing some Data in EditItemtemplate with TextBox & dropdown server controls.
 
Old July 26th, 2006, 01:16 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Please post some source.

"The one language all programmers understand is profanity."
 
Old July 26th, 2006, 02:07 PM
Authorized User
 
Join Date: Apr 2006
Posts: 79
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via AIM to anujrathi Send a message via MSN to anujrathi Send a message via Yahoo to anujrathi
Default

This is a part of the code. It contain textbox & required field validator. But when i press Update link button, no validator control work. Pls give me the solution!!

<EditItemTemplate>
<table>
<tr>
<td><asp:LinkButton Text="Update!" CommandName="Update" Runat="server" CausesValidation="True" /></td> <td><asp:LinkButton Text="Cancel!" CommandName="Cancel" Runat="server" CausesValidation="False" /></td>
</tr>
<tr>
<td align="right"><b>User ID:</b></td>
<td><%# DataBinder.Eval(Container.DataItem,"FacultyID") %></td>
</tr>
<tr> <td align="right"><b>Email ID:</b></td>
<td>
<asp:TextBox ID="txtEmailID" Text='<%# DataBinder.Eval(Container.DataItem,"EmailID") %>' Runat=server></asp:TextBox>
<asp:regularexpressionvalidator id="RegularExpressionValidator1" runat="server" ErrorMessage="Please enter a valid email" ControlToValidate="txtEmailID" ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">*</asp:regularexpressionvalidator>
</td></tr>
<tr>
<td align="right"><b>Company name:</b></td>
<td><asp:TextBox ID="txtCompanyName" Text='<%# DataBinder.Eval(Container.DataItem,"CompanyName") %>' Runat="server"></asp:TextBox> </td></tr>
</table>
</EditItemTemplate>
 
Old July 26th, 2006, 02:21 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Instead of placing the Update and Cancel buttons inside the EditItemTemplate, move them over to an EditCommandColumn. I do the same thing in the a datagrid as follows:

<asp:EditCommandColumn ItemStyle-VerticalAlign="Top" ItemStyle-Width="83" ButtonType="LinkButton" UpdateText="Update" HeaderText="Edit" CancelText="Cancel" EditText="Edit Record"></asp:EditCommandColumn>


    <asp:TemplateColumn ItemStyle-VerticalAlign="Top" ItemStyle-Width="75" HeaderText="DOB">
    <ItemTemplate>
        <asp:Label ID="Label4" Runat=server text='<%# Container.DataItem("DOB") %>' />
        </ItemTemplate>
        <EditItemTemplate>

     <asp:TextBox ID="txtDOB" MaxLength="10" CssClass="inputEdit" Text='<%# Container.DataItem("DOB") %>' Runat=server />
<asp:RegularExpressionValidator id="RegularExpressionValidator2" runat="server" ControlToValidate="txtDOB" ValidationExpression="\d{2}(\/|\\|-)\d{2}(\/|\\|-)\d{4}">Invalid</asp:RegularExpressionValidator>
    </EditItemTemplate>
</asp:TemplateColumn>

The above code works for me without problem.

hth.


"The one language all programmers understand is profanity."
 
Old July 26th, 2006, 03:32 PM
Authorized User
 
Join Date: Apr 2006
Posts: 79
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via AIM to anujrathi Send a message via MSN to anujrathi Send a message via Yahoo to anujrathi
Default

Hi Friend,
I m sorry to say, but i think u have not read my question carefully. I am talking about "DataList", not DataGrid & DataList does't hav any EditCommandColumn.
I hope, now u can give me a better solution.

Regards,
Anuj Rathi





Similar Threads
Thread Thread Starter Forum Replies Last Post
Validation controls and postback sdi126 ASP.NET 2.0 Basics 5 November 11th, 2007 12:08 PM
How to get to controls inside DataList? rsearing ASP.NET 2.0 Basics 1 March 1st, 2007 09:14 AM
User controls and validation relaytest49 ASP.NET 2.0 Professional 1 October 11th, 2006 01:25 PM
Validation Controls andyj00 ASP.NET 1.0 and 1.1 Professional 3 June 9th, 2005 09:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.