出于某种奇怪的原因,当我发出回发(通过单击按钮)时,页面执行回发,但结果页面完全空白。如果我尝试查看页面源代码,我会收到一条确认表单重新提交消息(使用 chrome)。
但是,如果我按 f5 几次,最终会加载正确的页面。
我注意到这通常发生在按下按钮导致某种数据库访问时。为什么会发生这种情况,我该如何避免?
编辑:我注意到,当我添加以下代码时,这种情况开始更频繁地发生,但它甚至在之前一直不时发生:
protected void BindPartList()
{
if (UnitsDropDown.Text == "Imperial")
{
if (PartListGridView.Columns.Count > 4)
PartListGridView.Columns.Remove(PartListGridView.Columns[4]);
BoundField colIndex4 = new BoundField();
colIndex4.DataField = "IMPUNITS";
colIndex4.HeaderText = "Unit";
colIndex4.SortExpression = "IMPUNITS";
PartListGridView.Columns.Add(colIndex4);
PartListGridView.DataSourceID = "ImpPartInfoObjectSource";
}
else
{
if (PartListGridView.Columns.Count > 4)
PartListGridView.Columns.Remove(PartListGridView.Columns[4]);
BoundField colIndex4 = new BoundField();
colIndex4.DataField = "DWGUNIT";
colIndex4.HeaderText = "Unit";
colIndex4.SortExpression = "DWGUNIT";
PartListGridView.Columns.Add(colIndex4);
PartListGridView.DataSourceID = "MetricPartInfoObjectSource";
}
PartListGridView.DataBind();
}
前端看起来像:
<asp:GridView ID="PartListGridView" runat="server" ShowHeaderWhenEmpty="True" AutoGenerateColumns="False"
Width="100%" Font-Size="11pt" DataKeyNames="PARTNUM" AllowSorting="true">
<Columns>
<asp:BoundField DataField="PARTNUM" HeaderText="PARTNUM" SortExpression="PARTNUM"
ReadOnly="True" />
<asp:BoundField DataField="PARTDESC" HeaderText="PARTDESC" SortExpression="PARTDESC" />
<asp:BoundField DataField="CATEGORY" HeaderText="CATEGORY" SortExpression="CATEGORY" />
<asp:BoundField DataField="COLOUR" HeaderText="COLOUR" SortExpression="COLOUR" />
</Columns>
</asp:GridView>
当然除了这两个数据源
谢谢,