Control not reflecting updates

211 views Asked by At

I have a master page that has an update panel on it. One of the pages for the application I'm working on has a custom control with some asp:textboxes on it. That control also has a gridview.

When an asp:linkbutton for a row is clicked the OnRowCommand event fires and does its magic correctly, one part of which is setting the asp:textbox's "Text" property. This works.

My problem is that the update isn't being reflected in the UI.

The UpdatePanel:

<asp:ScriptManager ID="scriptManager" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="updPanel" runat="server">
        <ContentTemplate>
              [...more code...]

The LinkButton:

 <ItemTemplate>
         <asp:LinkButton ID="LinkButton1" CommandArgument='<%# Eval("ID")%>' CommandName="EDIT" runat="server">Edit</asp:LinkButton>     
</ItemTemplate>

The Event Handler:

protected void RowCommand(object sender, GridViewCommandEventArgs e)
        {
            switch (e.CommandName)
            {
                case "EDIT":
                    //stuff happens here
                    [ASP:Textbox].Text = [Result of stuff that happened];
                     ^this is what isn't reflected on the page
                    break;

I know I'm missing something with the page life cycle but I'm drawing a blank.

2

There are 2 answers

2
Miroslav Zadravec On BEST ANSWER

Just spent few hours on this.

As it seems, changes are reflected only if CommandName property is set on something other then "Edit" (and any other standard commands). Try to set it to "EditThis", it works for me.

1
TheGeekYouNeed On
protected void RowCommand(object sender, GridViewCommandEventArgs e)
        {
            switch (e.CommandName)
            {
                case "EDIT":
                    //stuff happens here
                    [ASP:Textbox].Text = [Result of stuff that happened];
                     ^this is what isn't reflected on the page
                    // ADD THIS
                    updPanel.Update();
                    break;