title: asp.net GridView not showing correct data unless a postback event
body: <p>In my gridview, there is a column <code>IsYearly</code>. The value can be 1 or 0.</p>
  
  <p>On page load, the default values of all the data is 0, but when I update a data, the gridview will become what it is supposed to be on page load.</p>
  
  <p>Here is the gridview:</p>
  
  <pre><code>&lt;asp:GridView ID="gridView_Holidays" runat="server" AutoGenerateColumns="False" Style="margin-right: 10px; margin-top: 0px;" AllowPaging="True" OnPageIndexChanging="grdHolidays_PageIndexChanging" OnRowDataBound="grdHolidays_RowDataBound" PageSize="10" CssClass="table-grid"&gt;
          &lt;Columns&gt;
              &lt;asp:BoundField DataField="HolidayName" HeaderText="Name"&gt;
                  &lt;HeaderStyle BackColor="#0078D7" ForeColor="White" Width="320px" /&gt;
                  &lt;ItemStyle BackColor="White" ForeColor="Black" Width="320px" /&gt;
              &lt;/asp:BoundField&gt;
              &lt;asp:BoundField DataField="HolidayDate" HeaderText="Date"&gt;
                  &lt;HeaderStyle BackColor="#0078D7" ForeColor="White" Width="256px" /&gt;
                  &lt;ItemStyle BackColor="White" ForeColor="Black" Width="256px" /&gt;
              &lt;/asp:BoundField&gt;
              &lt;asp:BoundField DataField="HolidayID" HeaderText="Holiday ID"&gt;
                  &lt;HeaderStyle BackColor="#0078D7" ForeColor="White" CssClass="HideControl" /&gt;
                  &lt;ItemStyle BackColor="White" ForeColor="Black" CssClass="HideControl" /&gt;
              &lt;/asp:BoundField&gt;
              &lt;asp:BoundField DataField="HolidayIsYearly" HeaderText="Holiday Yearly"&gt;
                  &lt;HeaderStyle BackColor="#0078D7" ForeColor="White" CssClass="HideControl" /&gt;
                  &lt;ItemStyle BackColor="White" ForeColor="Black" CssClass="HideControl" /&gt;
              &lt;/asp:BoundField&gt;
  
              &lt;asp:TemplateField ItemStyle-Width="40px" HeaderText="" ItemStyle-CssClass="tblItem" HeaderStyle-CssClass="header"&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:ImageButton ID="imgBtnEditHoliday" runat="server" OnClick="lnkEditHoliday_Click" ImageUrl="~/Images/EDIT.GIF" ToolTip="Edit" /&gt;
                      &lt;asp:ImageButton ID="imgBtnDeleteHoliday" runat="server" Width="16px" OnClick="lnkDeleteHoliday_Click" ImageUrl="~/Images/deleteuser.png" ToolTip="Delete" /&gt;
                  &lt;/ItemTemplate&gt;
                  &lt;HeaderStyle BackColor="#0078D7" ForeColor="White" Font-Size="Medium" /&gt;
                  &lt;ItemStyle BackColor="White" ForeColor="Black" Font-Size="Medium" /&gt;
              &lt;/asp:TemplateField&gt;
          &lt;/Columns&gt;
  
          &lt;EmptyDataTemplate&gt;
              No results to show.
          &lt;/EmptyDataTemplate&gt;
      &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>The code behind:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e) {
              if (!IsPostBack) {
                  HolidayList();
                  imgBtnSearchApprover_Click(this, EventArgs.Empty);
              }
          }
  
          public void HolidayList() {
              Admin = new List&lt;DTR_Admin&gt;();
              Admin = mServiceHoliday.GetList();
              gridView_Holidays.DataSource = Admin;
              gridView_Holidays.DataBind();
          }
  </code></pre>
  
  <p>This is what happens when I click save button, where the gridview (i think) will refresh so it shows the correct data</p>
  
  <pre><code>protected void btnHolidaySave_Click(object sender, ImageClickEventArgs e) {
              if (string.IsNullOrEmpty(txtHolidayName.Text) || string.IsNullOrEmpty(txtHolidayDate.Text)) {
                  lblCostCenterError.Text = "Please complete all fields.";
                  ModalPopupExtender2.Show();
              }
              else {
                  if (Admin.Exists(x =&gt; (Convert.ToDateTime(x.HolidayDate) == Convert.ToDateTime(txtHolidayDate.Text) &amp;&amp; x.HolidayID != holidayID))) {
                      ClientScript.RegisterStartupScript(GetType(), "load", "alert('Date already exists.');", true);
                      ModalPopupExtender2.Show();
                  }
                  else {
                      DTR_HolidayService holidayService = new DTR_HolidayService();
                      DTR_Admin pEntity = new DTR_Admin();
                      pEntity.HolidayID = holidayID;
                      pEntity.HolidayDate = txtHolidayDate.Text;
                      pEntity.HolidayName = txtHolidayName.Text;
                      pEntity.HolidayIsYearly = cbYearly.Checked ? 1 : 0;
  
                      holidayService.EditHoliday(pEntity);
                      HolidayList();
                  }
              }
          }
  </code></pre>