By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,432 Members | 790 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,432 IT Pros & Developers. It's quick & easy.

Custom range validation in datagrid

P: n/a
I have a simple datagrid that shows configuration properties as Name : Value
pairs. I want to be able to programmatically change the validation controls
that apply based on the name field of the row that the user tries to edit.

So for example if the table shows:

TimeToHold 5
TimeToProcess 50

I would like to set limits on the range validator for TimeToHold between 3
and 10 and for TimeToProcess between 45 and 60 say.

I can't seem to reference the validation controls that are part of an
EditItemTemplate from within my OnEditCommand handler. Is there a way to do

The datagrid is defined like this in the aspx page:
<asp:datagrid ID="GridView1" runat="server"
AutoGenerateColumns="False" OnEditCommand="GridView1_EditCommand"
OnSelectedIndexChanged="GridView1_SelectedIndexCha nged">
<asp:TemplateColumn HeaderText="Name">
<asp:Label runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Name") %>'></asp:Label>
<asp:TemplateColumn HeaderText="Value">
<asp:Label runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Value") %>'></asp:Label>
<asp:TextBox ID="EditValue" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Value") %>'></asp:TextBox>
<asp:RangeValidator ID="RangeValidator1"
runat="server" ControlToValidate="EditValue"
<asp:EditCommandColumn CancelText="Cancel" EditText="Edit"

Sep 28 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.