views:

16

answers:

1

I have the following markup at the end of my Edit page template in a Dynamic Data project:

</asp:UpdatePanel>
<br />
<asp:Label ID="errorLabel" runat="server" Visible="false" ForeColor="Red">Helloooo</asp:Label>
<br />

And I have the following code in the code=behind for the template:

protected void DetailsView1_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
{
    if (e.Exception != null & !e.ExceptionHandled)
    {
        errorLabel.Text = e.Exception.Message;
        errorLabel.Visible = true;
        return;
    }
    Response.Redirect(table.ListActionPath);
}

The 'if' condition is true, and the errorLabel.Visible = true etc. executes, but the label remains invisible on the rendered screen. What am I doing wrong?

A: 

Your DetailsView is inside of the UpdatePanel, but your error label is outside of it. As such, the UpdatePanel does an async Postback and the error label does not get updated. Moving the error label to inside the UpdatePanel should fix your problem.

<asp:Label id="errorLable" runat="server" Visible="false" ForeColor="Red" />
</asp:UpdatePanel>
drovani