473,405 Members | 2,279 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Validator in gridview

Hi experts,

I need a validator in my gridview.
When the user update a field in the gridview, I need to check if the email is valid.
How can I do that?

Below is my gridview.
Please help. Thanks!

Expand|Select|Wrap|Line Numbers
  1. <asp:GridView ID="gv_retrieve" runat="server" AutoGenerateColumns="False" CellPadding="3"
  2.         ForeColor="Black" GridLines="Vertical" Width="751px" OnRowEditing="gv_retrieve_RowEditing" 
  3.         OnRowUpdating="gv_retrieve_RowUpdating" onRowCancelingEdit = "gv_retrieve_RowCancelingEdit" 
  4.         OnRowDeleting = "gv_retrieve_RowDeleting" OnRowDataBound = "gv_retrieve_RowDataBound"
  5.         BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" Font-Bold="False">
  6.         <FooterStyle BackColor="#CCCCCC" />
  7.  
  8.         <Columns>
  9.  
  10.             <asp:BoundField DataField="Name" HeaderText="Name" />
  11.             <asp:BoundField DataField="Designation" HeaderText="Designation" />
  12.             <asp:BoundField DataField="Email" HeaderText="Email Address" />
  13.             <asp:BoundField DataField="WatcherEmail" HeaderText="Watcher Email" />
  14.             <asp:CommandField ShowEditButton="True" >
  15.                 <ItemStyle Width="35px" />
  16.             </asp:CommandField>
  17.             <asp:CommandField ShowDeleteButton="True" />
  18.             <asp:BoundField DataField="apid">
  19.                 <ItemStyle CssClass="hiddencol" />
  20.             </asp:BoundField>
  21.         </Columns>
  22.         <EmptyDataTemplate>
  23.             <table width="100%">
  24.                 <tr style="font-weight:bold; text-decoration:underline" align="center">
  25.                     <td>
  26.                         Name
  27.                     </td>
  28.                     <td>
  29.                         Designation
  30.                     </td>
  31.                     <td>
  32.                         Email
  33.                     </td>
  34.                     <td>
  35.                         WatcherEmail
  36.                     </td>
  37.                 </tr>                                                                                  
  38.             </table>                        
  39.              <br />
  40.         </EmptyDataTemplate>
  41.         <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
  42.         <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
  43.         <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
  44.         <AlternatingRowStyle BackColor="#CCCCCC" />
  45.     </asp:GridView>
Nov 28 '07 #1
1 1171
Hi,

sorry i dint understand your code, but i understood your problem. you can just try the below code

<asp:GridView runat="server" ID="gvMaster" AutoGenerateColumns="False" HorizontalAlign="Left"
CellPadding="0" ForeColor="#333333" Font-Size="8pt" BorderStyle="Groove"
AllowPaging="True" PageSize="12" DataKeyNames="item_code" Font-Names="Tahoma"
Font-Underline="False" Width="80%" ShowFooter="True">
<columns>

<asp:TemplateField HeaderText="Email">
<EditItemTemplate>
<asp:TextBox ID="gvEEmail" runat="server" Width="60px"></asp:TextBox>
<asp:RegularExpressionValidator ID="regvEmail" runat="Server" ControlToValidate="gvEEmail" Display="dynamic"
SetFocusOnError="true" Font-Names="Tahoma" ValidationExpression="^[\w-\.]+@([\w-]+\.){1,2}[\w-]{2,4}$"
Font-Size="8pt">Enter proper mail id</asp:RegularExpressionValidator>
</EditItemTemplate>
</columns>

</gridview>

you can do the same for Footertemplate
Nov 28 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: =?Utf-8?B?SGF3aw==?= | last post by:
Hello, I have been trying to get a duplicate field checker to work within my gridview using a custom validator. However with the code I have I am getting an error error: Object reference not...
0
by: SAL | last post by:
Okay, understanding the problem a little better now. I have a gridview that is enabled for editing. I want users to be able to add data to the gridview also so I turn the fields into Templates and...
6
by: mathewgk80 | last post by:
Hi all, I have two textboxes, txtName and txtDescription. i added required field validator to both of them. I have a Gridview in the same page. In tht gridview, i have a template field...
1
by: dan | last post by:
Hi, How do I make sure that RequiredFieldValidator attached to a textbox column of a gridview is displayed on the right side of the field and not underneath? This is in edit mode of a gridview?...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.