Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Formview and FindControl
Message
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Novell 5.x
Database:
MS SQL Server
Miscellaneous
Thread ID:
01349103
Message ID:
01349108
Views:
25
I think you need to call Validate method of the control. I have some pages where we display error messages when we bring the form. If you need some code, remind me on Monday, please.

>I have been trying to reference a control (A CustomValidator) within a Formview's EditTemplate in order to display an error message on an exception generator by the violation of a trigger or an index. I can get the control. I can set the property. But when the page refreshes nothing has actually happened. What am I missing?
>
>Thanks
>Richard
>
>Code:
>
>        protected void formviewEditClient_ItemUpdated(object sender, FormViewUpdatedEventArgs e)
>        { 
>            bool hasErrors = false;
>            SqlException sqlexception;
>
>            if(e.Exception != null)
>            {
>                hasErrors = true;
>
>                if(e.Exception.InnerException.GetType() == typeof(SqlException))
>                {
>                    sqlexception = (SqlException)e.Exception.InnerException;
>
>                    switch(sqlexception.Number)
>                    {
>                        case 2627:
>                        {
>                            Label lb = (Label)this.formviewEditClient.FindControl("labelTester");
>                            lb.Text = "Testing of internal.";
>
>                            CustomValidator cv = (CustomValidator)this.formviewEditClient.FindControl("CustomValidator2");
>                            cv.IsValid = false;
>                            e.ExceptionHandled = true;
>                            e.KeepInEditMode = true;
>
>                            break;
>                        }
>                    }
>
>                }
>            }
>
>            if(!hasErrors)
>            {
>                Response.Redirect("~/WebForms/Main.aspx");
>            }
>
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform