views:

181

answers:

3
+3  Q: 

update panel issue

For whatever reason - my update panel is not updating. Now please note that this is all inside the item template of a template field inside of a gridview. Major Nesting. Help me,Please

<ItemTemplate>
   <asp:ImageButton ID="bttnEdit" runat="server" injid='<%# Eval("Id") %>' causeid='<%# Eval("Cause_Type") %>' natureid='<%# Eval("Nature_Type") %>' CausesValidation="False" ImageUrl="~/images/bttnEdit.gif" Text="Edit" OnClientClick ="loadmodal(this.injid,this.causeid,this.natureid);"  />
   &nbsp;<asp:ImageButton ID="ImageButton2" runat="server" CausesValidation="False" 
   CommandName="Delete" ImageUrl="~/images/bttnDelete.gif" Text="Delete" />
   <asp:Panel ID = "Pnlmodal" runat ="server" style="background-color:White; padding:1em 6px;">  
      <asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Conditional"  >
      <Triggers>
         <asp:AsyncPostBackTrigger ControlID ="bttnEdit" EventName ="Click" />
      </Triggers>
         <ContentTemplate>
            <asp:FormView ID="FormView2" runat="server" DefaultMode ="Edit" DataSourceID ="SqlDataSource8">
               <EditItemTemplate>
                  <table>
                     <tr>
                     <td colspan="2" align="center" style="color:Blue;font-size:large">Edit Injury</td>
                     </tr>
                     <tr><br /></tr>
                     <tr>
                        <td align="right" ><strong>What event caused the injury?</strong></td>
                        <td align="left">
                           <asp:DropDownList ID="ddlcauseofinj" onchange="showifother('1');" runat="server" 
                           DataSourceID="SqlDataSource2" DataTextField="Description" 
                           DataValueField="ID" AppendDataBoundItems="True">
                              <asp:ListItem Selected="True" style="color:gray" Value="0">Causes of Injury</asp:ListItem>
                           </asp:DropDownList>
                        </td>
                     </tr>
                     <tr id="trother1"  style="display:none">
                        <td align ="right"><strong>If Other, Please Describe:</strong></td>
                        <td align="left">
                        <asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine"></asp:TextBox>
                        </td>
                     </tr>
                     <tr>
                        <td align="right"><strong>What is the extent of the Injury?</strong></td>
                        <td align="left">
                           <asp:DropDownList ID="ddlextentofinj" runat="server" 
                           onchange="showifother('2');" AppendDataBoundItems ="true"  DataSourceID="SqlDataSource3" 
                           DataTextField="Description" DataValueField="ID">
                           <asp:ListItem Selected="True" style="color:gray" Value="0">Extent of the Injury</asp:ListItem>
                           </asp:DropDownList>
                        </td>
                     </tr>
                     <tr id="trother2"  style="display:none">
                        <td align="right"><strong>If Other, Please Describe:</strong></td>
                        <td align="left">
                           <asp:TextBox ID="TextBox4" runat="server" TextMode="MultiLine" ></asp:TextBox>
                        </td>
                     </tr>
                     <tr>
                        <td align="right"><strong>Type of Medical Treatment:</strong></td>
                        <td align ="left">
                           <asp:DropDownList ID="DropDownList3" AppendDataBoundItems ="true"  runat="server" 
                           DataSourceID="SqlDataSource4" DataTextField="Description" DataValueField="ID">
                           <asp:ListItem Selected="True" style="color:gray" Value="0">Medical Treatments</asp:ListItem>
                           </asp:DropDownList>
                        </td>
                     </tr>
                     <tr>
                        <td align="right"><strong>Treatment Provider:</strong></td>
                        <td align="left">
                           <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Injury_Desc")%>'></asp:TextBox>
                        </td>
                     </tr>
                     <tr>
                        <td colspan ="2" align="center"><asp:ImageButton ID="CancelButton" runat="server" ImageUrl="~/images/bttnCancel.gif" /></td>
                     </tr>
                  </table>
               </EditItemTemplate>
            </asp:FormView>
         </ContentTemplate>
      </asp:UpdatePanel>
   </asp:Panel>
   <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" 
   TargetControlID="bttnEdit" PopupControlID="Pnlmodal" 
   BackgroundCssClass="modalBackground" Drag="True" />
</ItemTemplate>
A: 

I'm guessing you're having problems with bttnEdit being clicked and not causing your UpdatePanel to refresh, even tho you have an explicitly defined trigger.

If that's the case, you're problem could be revolving around the fact that you do not actually have a server side click event defined for bttnEdit. Instead, you hijack the click with javascript, and probably use that to submit your form without ever passing to the server that bttnEdit was clicked.

tl;dr: Change your bttnEdit to also do a server side click, or change your updatepanel to always update (the second one is an ugly hack)

JustLoren
I changed it to always update but it doesn't seem to update. I have the onclient click because i set a variable to something that the formview's datasource depends on. So i need that updatepanel to update. I've tried dopostback in javascript but it just reloads the whole page.
Eric
You can have an onclientclick and an onclick - they co-exist for a reason. I was merely suggesting you use both, as that should have resolved your issues.
JustLoren
+1  A: 

I just wrap the update panel around the whole site. This seams to usually do the trick. The fact you have an update panel in a grid view probably messes up the id of the panel and causes it not to update.

  1. just wrap the gridview in the panel

  2. try the whole site

Paul
Wrapping the whole page in an updatepanel is fine if you don't care about performance. Personally, I UpdateMode=Conditional all of my update panels, and only wrap appropriate sections.
JustLoren
A: 

Thanks for all of your answers! I moved the entire panel outside of the gridview and all the other nested controls. It worked. It was having issues finding Control Id's.

Eric
Having done update panels inside gridviews, I cannot say that I agree that this was the correct answer. I think you just opened the door using an axe instead of the doorknob. Both accomplish the same things, but one's a little bit more hacky :)
JustLoren