Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Formview and FindControl
Message
General information
Forum:
ASP.NET
Category:
Other
Title:
Formview and FindControl
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Novell 5.x
Database:
MS SQL Server
Miscellaneous
Thread ID:
01349103
Message ID:
01349103
Views:
72
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");
            }
State of Florida, DCF
Next
Reply
Map
View

Click here to load this message in the networking platform