473,804 Members | 3,745 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GridView ItemTemplate - Validators not being called

Mel
I have a GridView that is bound to a DataTable. I decided to allow
the user to change the column data right in the ItemTemplate. Then
user won't need to click Edit to change the values and then click
Update to save them because for this application the user will need to
edit the data in every row so I thought the ItemTemplate would be a
better solution. However, when I place the controls in my
ItemTemplate my Validators are not being called at all when they enter
invalid data. Won't the GridView work this way?

Here is a small snippet of one item template column:
<asp:TemplateFi eld HeaderText="Dur ation (days)"
SortExpression= "Duration">
<EditItemTempla te>
</EditItemTemplat e>
<ItemTemplate >
<asp:TextBox ID="txtDuration " runat="server" Text='<%#
Bind("[Duration]") %>' Width="56px" CausesValidatio n="True"
Wrap="False" ValidationGroup ="AllValidators "></asp:TextBox><br />
<asp:RequiredFi eldValidator ID="rfvDuration " runat="server"
ControlToValida te="txtDuration "
ErrorMessage="E nter a Duration (number of days)."
SetFocusOnError ="True" Display="Dynami c"
ValidationGroup ="AllValidators "></asp:RequiredFie ldValidator><br />
<asp:RangeValid ator ID="rvDuration " runat="server"
ControlToValida te="txtDuration "
ErrorMessage="E nter a number between 0 and 365 days."
MaximumValue="3 65"
MinimumValue="0 " SetFocusOnError ="True" Display="Dynami c"
Type="Integer" ValidationGroup ="AllValidators "></asp:RangeValida tor>
</ItemTemplate>
<ItemStyle VerticalAlign=" Top" />
</asp:TemplateFie ld>
Oct 31 '08 #1
1 5177
the control triggering the postback has to have causes validation set to
true, and have the validation group set to match your specification.

-- bruce (sqlwork.com)
"Mel" wrote:
I have a GridView that is bound to a DataTable. I decided to allow
the user to change the column data right in the ItemTemplate. Then
user won't need to click Edit to change the values and then click
Update to save them because for this application the user will need to
edit the data in every row so I thought the ItemTemplate would be a
better solution. However, when I place the controls in my
ItemTemplate my Validators are not being called at all when they enter
invalid data. Won't the GridView work this way?

Here is a small snippet of one item template column:
<asp:TemplateFi eld HeaderText="Dur ation (days)"
SortExpression= "Duration">
<EditItemTempla te>
</EditItemTemplat e>
<ItemTemplate >
<asp:TextBox ID="txtDuration " runat="server" Text='<%#
Bind("[Duration]") %>' Width="56px" CausesValidatio n="True"
Wrap="False" ValidationGroup ="AllValidators "></asp:TextBox><br />
<asp:RequiredFi eldValidator ID="rfvDuration " runat="server"
ControlToValida te="txtDuration "
ErrorMessage="E nter a Duration (number of days)."
SetFocusOnError ="True" Display="Dynami c"
ValidationGroup ="AllValidators "></asp:RequiredFie ldValidator><br />
<asp:RangeValid ator ID="rvDuration " runat="server"
ControlToValida te="txtDuration "
ErrorMessage="E nter a number between 0 and 365 days."
MaximumValue="3 65"
MinimumValue="0 " SetFocusOnError ="True" Display="Dynami c"
Type="Integer" ValidationGroup ="AllValidators "></asp:RangeValida tor>
</ItemTemplate>
<ItemStyle VerticalAlign=" Top" />
</asp:TemplateFie ld>
Oct 31 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6554
by: Robert Smith jr. | last post by:
Hello, Please pardon my newbie question ... I am building an ASP.NET page that displays a recordset with a Delete statement enabled (this all works fine). I want to Insert the current row *that is going to be deleted* into another table, before the original data is deleted. I am trying to use the RowDeleting method to call an Update or Insert
0
5242
by: danc | last post by:
I am trying to modify the layout of a row based on the value in some data (I am creating a subtotal line). This works fine when the page is first loaded, but when it's reloaded, the wrong column is restored. <asp:GridView ID="grdvOrder" runat="server" AutoGenerateColumns="False" OnRowCommand="grdvOrder_RowCommand" OnRowDataBound="grdvOrder_RowDataBound" OnRowCreated="grdvOrder_RowCreated"> <Columns> <asp:TemplateField...
0
2393
by: Mike P | last post by:
Where exactly are the updateparameters of a gridview picked up from? I have created 2 very similar gridviews and given the updateparameters the same names as in my edititemtemplates. Yet this method has worked for 1 gridview and failed for the second gridview. Here is my gridview : <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:XConnectionString %>" SelectCommand="ViewForecast"...
0
2481
by: Mike P | last post by:
I am trying to edit a gridview while using paging, but whenever I try to edit a row on a page other than page 1, I get an error. Here is my gridview and my code : <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="UserKey" AllowSorting="True" HeaderStyle-Height="24px" AutoGenerateColumns="false" SkinID="Grey3" EditRowStyle-CssClass="dgedit"
0
2000
by: =?Utf-8?B?TGFkaXNsYXYgTXJua2E=?= | last post by:
Hello, I read some msdn and other articles about how does databinding among DataSource controls and FormView / GridView controls works but I still don't fully understand to this blackbox. I have few questions and hopefully you can provide me some answers. 1. Best place for DataBinding. Where is the best place for calling DataBind method? Is it possible to say don't bind controls for this postback and use current values instead? These...
0
2762
by: ballamber | last post by:
This is a solution to the problem. Works with .NET 2.0. So the problem is displaying a data bound read-only checkbox or radio button in a GridView without actually disabling those controls. I assume you know what templates are in a GridView. Examples are in VB.NET. Sorry... So as a first step create a function in the page's underlying class that returns the string "checked" based on the bound data. Here's what I did. The underlying data...
2
2536
by: CJM | last post by:
I have a page that allows the user to search a DB by querying one of 3 fields. When results are returned, I want the user to be able to click a value in one of three columns (that directly relate to the 3 searchable fields) and have the page postback and requery given the selected criterion. For example, the user searches for retainer #1, which has a Tip Width of 5. So he clicks on the 5 and it searches again for all retainers that have a...
3
2655
by: RobertTheProgrammer | last post by:
Hi folks, I've got another problem. Basically, I'm trying to use a nested GridView, however the nexted GridView displays no values (even though in debug I'm getting valid values into my DataSet. It's probably a binding issue somewhere, but I'm not sure where. Here's the ASP (slightly edited to remove verbosity): <asp:GridView ID="GridViewMain" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" ...
1
1851
nitindel
by: nitindel | last post by:
Hi All, Please tell me any good site for Gridview control.(not for datagrid). I am facing error in fetching the values of the Bound columns in the gridview: lease tell me how should i fetch the value..of a bound column..?? Below is the code.:
0
9706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9584
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9160
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3822
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2995
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.