0

I have a table within an updatepanel and it displays the information as the page loads. When I press a button the updatepanel refreshes and the information goes away. In debug it shows it looping through but not displaying on website.

<div class="col-xs-12 col-md-6" style="margin-top: 10px;">
        <div id="notificationsTab" class="tab" style="background-color: #AD816B;">
            <a style="color: black; text-decoration: none;">&nbsp;Notification</a>
            <div id="button3" class="button4">
            </div>
        </div>
        <div class="toggler2">
            <div id="effect2" class="">
                <asp:UpdatePanel ID="notifications" runat="server" BackColor="#AD816B" BorderColor="#724229"
                    BorderStyle="Inset" class="notifications" UpdateMode="Conditional">
                    <ContentTemplate>
                    <div class="mCustomScrollbar content3 fluid light">
                        <div class="notificationsDay">
                            <table id="testingtesting">
                                <tr>
                                    <td style="width: 15%">
                                        Action
                                    </td>
                                    <td style="width: 55%">
                                        Description
                                    </td>
                                    <td style="width: 30%">
                                        Date Added
                                    </td>
                                </tr>
                                <% for (int i = 0; i <= ***.Count - 1; i++)
                                   {
                                       string action = Get2DHashtableElement(*** i, "***");
                                %>
                                <tr>
                                    <%if (action == "Checked In Appt")
                                      {%>
                                    <td>
                                        <center>
                                            <a class="fancybox fancybox.iframe" href=***?id=<%= Get2DHashtableElement(***, i, "***")%>'>
                                                <img src="images/httpzcoolcomcnpicpngpng_7420png.png" border="0" style="height: 25px;
                                                    width: 25px;" /></a>
                                        </center>
                                    </td>
                                    <%} %>
                                    <td>
                                        <%= Get2DHashtableElement(mhc_notification, i, "Description")%>
                                    </td>
                                    <td>
                                        <%= Get2DHashtableElement(mhc_notification, i, "AddedDate")%>
                                    </td>
                                </tr>
                                <%} %>
                            </table>
                        </div>
                    </div>
                    </ContentTemplate>
                    <Triggers>
                     <asp:AsyncPostBackTrigger ControlID="btnTesting" EventName="Click" />
                    </Triggers>
                </asp:UpdatePanel>
            </div>
        </div>
    </div>

The button is a simple button

<asp:Button ID="btnTesting" runat="server" onclick="btnTesting_Click" 
                        Text="Action" />

and here is the c#

 protected void btnTesting_Click(object sender, EventArgs e)
{
    using (SqlConnection connection = new SqlConnection(strConnString))
    {
        int sKey = Convert.ToInt32(ViewState["sKey"]);
        DateTime now = DateTime.Now;
        string today = now.ToString("MM/dd/yyyy");
        SqlCommand cmd = new SqlCommand("INSERT INTO *** (Staffkey, ClientKey, ActionKey, Description) VALUES (@Staffkey, @ClientKey, @ActionKey, @Description)");
        cmd.CommandType = CommandType.Text;
        cmd.Connection = connection;
        cmd.Parameters.AddWithValue("@Staffkey", sKey);
        cmd.Parameters.AddWithValue("@ClientKey", **);
        cmd.Parameters.AddWithValue("@ActionKey", "Checked In Appt");
        cmd.Parameters.AddWithValue("@Description", "test , greg2 is Checked in for their" + today + "Appointment");
        connection.Open();
        cmd.ExecuteNonQuery();
    }

All it does is add someone to the database and is supposed to update the table after add. I don't want to refresh the whole page just the panel.

I've looked around but mostly all I see is gridviews. I also tried jquery.load and tried to reload the div its self to see if that would work but to no evail. }

KratosMafia
  • 333
  • 1
  • 16
  • 2
    Just out of curiosity, have you tried changing the update mode to UpdateMode="Always" ? – Moe Nov 09 '15 at 19:38
  • Sorry thought I Put that. I did do that. When I put it to always then the information doesn't even display on page load. – KratosMafia Nov 09 '15 at 19:39
  • In that case you should try notifications.Update() on the button click method. – Darren Gourley Nov 09 '15 at 19:40
  • I believe you should be using PostBackTrigger instead of AsyncPostBackTrigger http://stackoverflow.com/questions/4912614/what-is-the-different-between-asyncpostbacktrigger-postbacktrigger-really – Moe Nov 09 '15 at 19:41
  • 2
    Only if the button is in the update panel and childrenastriggers is true. This is bringing back too many bad memories! – Darren Gourley Nov 09 '15 at 19:44
  • 1
    ahh yea tried that but it does a postback on the whole page. But it was not working. But with the notifications.Update() with the PostBackTrigger the information is loading on postback but the whole page is reloading. So thamls @Moe for that option. Now is the issue of whole page. I can try to find that online though or something xD – KratosMafia Nov 09 '15 at 19:45
  • Just remembered, do you have this at the top of your page? . . . – Darren Gourley Nov 09 '15 at 20:00
  • so no idea what I did. Was messing around with it forever and changed postbacktrigger to AsyncPostBackTrigger and it started to work right. Will not lie and say I have no idea how I did it. Thanks to everyone though. All of your suggestions were tried and some helped. Think the notification.update() with asyc is what did it. – KratosMafia Nov 09 '15 at 20:21

0 Answers0