You are implementing a read-only page that includes the following controls.
<asp:Button ID=”btnRefresh” runat=”server” Text=”Button” />
<asp:GridView ID=”gvCustomers” runat=”server” EnableViewState=”False” OnDataBinding=”gvCustomers_DataBinding”></asp:GridView>
You disable view state to improve performance.
You need to ensure that the page is updated to display the latest data when the user clicks the refresh button.
Which code segment should you use?
A.
protected void Page_PreInit(object sender, EventArgs e)
{
if (!IsPostBack)
{
gvCustomers.DataSource = GetCustomers();
gvCustomers.DataBind();
}
}
B.
protected void Page_Load(object sender, EventArgs e)
{
gvCustomers.DataSource = GetCustomers();
gvCustomers.DataBind();
}
C.
protected void gvCustomers_DataBinding(object sender, EventArgs e)
{
gvCustomers.DataSource = GetCustomers();
gvCustomers.DataBind();
}
D.
protected void Page_PreRender(object sender, EventArgs e)
{
if (!IsPostBack)
{
gvCustomers.DataSource = GetCustomers();
gvCustomers.DataBind();
}
}