【发布时间】:2017-06-08 06:39:46
【问题描述】:
我正在使用 Daypilot 日历。
我遇到的问题是,每当发生更改时,例如日历上的 EventResize 或 EventMove,Gridview 都应该使用最新值进行更新
示例事件调整大小
protected void DayPilotCalendar1_EventResize(object sender, EventResizeEventArgs e)
{
int id = e.Recurrent ? Convert.ToInt32(e.RecurrentMasterId) : Convert.ToInt32(e.Id);
new DataManager_MasterRota().MoveAssignment(id, e.NewStart, e.NewEnd, e.NewStart.DayOfWeek);
DayPilotCalendar1.DataSource = new DataManager_MasterRota().GetAssignmentsForLocation(DayPilotCalendar1);
DayPilotCalendar1.DataBind();
DayPilotCalendar1.Update();
GridView1.DataBind();
}
当事件被调整大小时 Gridview1.DataBind() 被触发,但它实际上并没有刷新 gridview 上的数据。我必须按 F5 刷新页面才能真正影响 Gridview。
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4" ForeColor="Black" GridLines="Vertical" Width="94px" DataSourceID="SqlDataSource1">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="PersonId" HeaderText="PersonId" SortExpression="PersonId" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" ReadOnly="True" />
<asp:BoundField DataField="a" HeaderText="a" ReadOnly="True" SortExpression="a" />
</Columns>
<FooterStyle BackColor="#CCCC99" />
<HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
<RowStyle BackColor="#F7F7DE" />
<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#FBFBF2" />
<SortedAscendingHeaderStyle BackColor="#848384" />
<SortedDescendingCellStyle BackColor="#EAEAD3" />
<SortedDescendingHeaderStyle BackColor="#575357" />
</asp:GridView>
【问题讨论】:
-
您的网格视图在某个面板中?
-
我在里面和没有更新面板的情况下都试过了,结果是一样的,刷新更新gridview数据失败
-
我实际上将 EventResize 更改为回发并且它有效。是否可以使用回调?
-
是的,因为网格中的数据是缓存的,更新后不会刷新。
-
我可以使用回调而不是回发来更新 Gridview 吗?
标签: c# asp.net gridview daypilot