validating a custom control in a datagrid

P

philipl

hi,

i have a datagrid which display custom controls when user clicks edit,
changing data. I am using customvalidator to validate this control. I
can get validation of user input to work no problem when user clicks
on update in datagrid.

My problem is that when I try to get customvalidation to work when
user changes the value in the control, as i want this to be checked as
soon as user changes the control. The custom control offers an
OnServerChanged event which I can call the customvalidation but I
don't know how to access my custom validation control when I am in
this event. Does any know how i can do this?

Here is my code:

<asp:TemplateColumn HeaderStyle-CssClass="header"
HeaderText="Language">
<ItemTemplate>
<asp:Label runat="server" ID="lang"
Text='<%#DataBinder.Ev(Container.DataItem, "langname")%>'/>
</ItemTemplate>
<EditItemTemplate>
<ccl:combobox id="langEntry"
autopostback="true" runat="server" Style="FONT-FAMILY:verdana"
DataSource='<%# ListLanguageList() %>' DataTextField="lang"
DataValueField="langID">
</ccl:combobox>
<asp:CustomValidator
id="customcbval" Runat="server" ControlToValidate="langEntry"
OnServerValidate="cbLangCheck"
ErrorMessage="You must select
language from list" Display="Dynamic"></asp:CustomValidator>
</EditItemTemplate>
</asp:TemplateColumn>



//code-behind function which gets called when my custom control
changes

protected void langentry_textchanged(object sender, System.EventArgs
e)
{
// don't know how i can call my customvalidatot here
}
 
J

John Saunders

hi,

i have a datagrid which display custom controls when user clicks edit,
changing data. I am using customvalidator to validate this control. I
can get validation of user input to work no problem when user clicks
on update in datagrid.

My problem is that when I try to get customvalidation to work when
user changes the value in the control, as i want this to be checked as
soon as user changes the control. The custom control offers an
OnServerChanged event which I can call the customvalidation but I
don't know how to access my custom validation control when I am in
this event. Does any know how i can do this?

Here is my code:

<asp:TemplateColumn HeaderStyle-CssClass="header"
HeaderText="Language">
<ItemTemplate>
<asp:Label runat="server" ID="lang"
Text='<%#DataBinder.Ev(Container.DataItem, "langname")%>'/>
</ItemTemplate>
<EditItemTemplate>
<ccl:combobox id="langEntry"
autopostback="true" runat="server" Style="FONT-FAMILY:verdana"
DataSource='<%# ListLanguageList() %>' DataTextField="lang"
DataValueField="langID">
</ccl:combobox>
<asp:CustomValidator
id="customcbval" Runat="server" ControlToValidate="langEntry"
OnServerValidate="cbLangCheck"
ErrorMessage="You must select
language from list" Display="Dynamic"></asp:CustomValidator>
</EditItemTemplate>
</asp:TemplateColumn>



//code-behind function which gets called when my custom control
changes

protected void langentry_textchanged(object sender, System.EventArgs
e)
{
// don't know how i can call my customvalidatot here
}

You shouldn't need to call your custom validator. It should be called in the
normal course of events, when Page.Validate is called.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top