更新面板没有工作 [英] Update panels not woking
问题描述
我正在创建一个包含3个图表和一个网格的仪表板。
所有图表和网格都放在单独的UpdatePanel中,并且是从单独的C#方法绑定的,这些方法都在Page_LoadComplete中调用( )。
问题:在点击GridView的页面索引时,所有控件都会获得Postback以及各自的UpdatePanel。我不想要这个。
我只想要那个控件必须回发我想要的,就像我点击网格的页面索引一样那个网格回发不是所有的控件。
这是我的HTML(.aspx)代码:
I''m creating a Dashboard with 3 Charts and a Grids.
All the charts and grids are placed in separate UpdatePanel and are binding from separate C# methods which all are getting called in Page_LoadComplete().
Problem: On clicking the page index of GridView, all the controls are getting Postback withing their respective UpdatePanels. I don''t want this.
I want only that control must postback which i want, As like, if i click the grid''s page index, only that grid postback not all the controls.
This is my HTML(.aspx) Code:
<div class="col-md-12">
<div class="row">
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<div class="col-md-6">
<div style="border: 2px solid #202020; height: 351px; border-radius: 10px; width: 505px; margin-removed -21px;">
<div style="background-color: rgb(0, 202, 121); border-radius: 7px; margin-removed -1px; border: 2px solid #202020; width: 501px; height: 40px;">
Running Project Status
</div>
<asp:Chart ID="Chart1" runat="server" Width="500px" ImageLocation="ChartPic_#SEQ(300,3)">
<Series>
<asp:Series Name="Complete (%)" ChartType="Bar" IsValueShownAsLabel="true" Color="SteelBlue" XValueMember="ProjectNameTech" IsVisibleInLegend="true" YValueMembers="Percentage"></asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1"></asp:ChartArea>
</ChartAreas>
<Legends>
<asp:Legend Alignment="Center" Docking="Bottom" IsTextAutoFit="false" Name="Default" LegendStyle="Column"></asp:Legend>
</Legends>
</asp:Chart>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<div class="col-md-6">
<div style="border: 2px solid #202020; height: 351px; border-radius: 10px; width: 505px; margin-removed -10px;">
<div style="background-color: rgb(0, 202, 121); border-radius: 7px; margin-removed -1px; border: 2px solid #202020; width: 501px; height: 40px;">
Upcomming Demos
</div>
<asp:Chart ID="Chart2" runat="server" Width="500px" ImageLocation="~/images/TempImages/ChartPic_#SEQ(300,3)">
<Series>
<asp:Series Name="Demo Date" ChartType="Point" IsValueShownAsLabel="True" Color="Maroon" XValueMember="ProjectNameTech" YValueType="Date" YValueMembers="DemoRescheduleDate" ChartArea="ChartArea1" Legend="Default"></asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1"></asp:ChartArea>
</ChartAreas>
<Legends>
<asp:Legend Alignment="Center" Docking="Bottom" IsTextAutoFit="false" Name="Default" LegendStyle="Column"></asp:Legend>
</Legends>
</asp:Chart>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<%--Row 1 Ends Here--%><br />
<div class="row">
<asp:UpdatePanel ID="UpdatePanel4" runat="server">
<ContentTemplate>
<div class="col-md-6">
<div style="border: 2px solid #202020; height: 351px; border-radius: 10px; width: 505px; margin-removed -21px;">
<div style="background-color: rgb(0, 202, 121); border-radius: 7px; margin-removed -1px; border: 2px solid #202020; width: 501px; height: 40px;">
Upcomming Deployments
</div>
<asp:Chart ID="Chart3" runat="server" Width="500px" ImageLocation="~/images/TempImages/ChartPic_#SEQ(300,3)">
<Series>
<asp:Series Name="Delpoyment Date" ChartType="Point" IsValueShownAsLabel="True" Color="#288a81" XValueMember="ProjectNameTech" YValueType="Date" YValueMembers="EndDate" ChartArea="ChartArea1" Legend="Default"></asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1"></asp:ChartArea>
</ChartAreas>
<Legends>
<asp:Legend Alignment="Center" Docking="Bottom" IsTextAutoFit="false" Name="Default" LegendStyle="Column"></asp:Legend>
</Legends>
</asp:Chart>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<%--Row 2 Ends Here--%><br />
<div class="row">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div class="col-md-6">
<div style="border: 2px solid #202020; height: 351px; border-radius: 10px; width: 1021px; margin-removed -21px;">
<div style="background-color: rgb(0, 202, 121); border-radius: 7px; margin-removed -1px; border: 2px solid #202020; width: 1018px; height: 40px;">
Project Payment Detail
</div>
<br />
<div class="table-responsive">
<asp:GridView ID="GridView1" runat="server" HeaderStyle-Height="38px" AllowSorting="true" Height="262px" PageSize="5" AllowPaging="true" Style="width: 987px; margin-left: 15px;" HeaderStyle-BackColor="#00ca79" CssClass="table table-bordered table-hover" AutoGenerateColumns="False" OnPageIndexChanging="GridView1_PageIndexChanging">
<Columns>
<asp:BoundField DataField="ClientFullName" ItemStyle-Height="38px" HeaderText="Client Name"></asp:BoundField>
<asp:BoundField DataField="ProjectNameTech" HeaderText="Project Name"></asp:BoundField>
<asp:BoundField DataField="ProjectCost" HeaderText="Project Cost"></asp:BoundField>
<asp:BoundField DataField="Payment" HeaderText="Payment"></asp:BoundField>
<asp:BoundField DataField="Due" HeaderText="Due"></asp:BoundField>
<asp:BoundField DataField="PaymentDate" HeaderText="Last Payment"></asp:BoundField>
<asp:BoundField DataField="Percentage" HeaderText="Complete (%)" ItemStyle-Width="105px"></asp:BoundField>
</Columns>
</asp:GridView>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
This Is My C#(.aspx.cs) Code
This Is My C#(.aspx.cs) Code
protected void Page_LoadComplete(object sender, EventArgs e)
{
BDMDashboardProjectStatus();
ProjectCompleted();
BDMDashboardDemo();
}
public void BDMDashboardProjectStatus()
{
DataTable dtProjectStatus = objBAL.BDMDashboardProjectStatusBAL();
if (dtProjectStatus.Rows.Count > 0)
{
GridView1.DataSource = dtProjectStatus;
GridView1.DataBind();
}
if (dtProjectStatus.Rows.Count > 0)
{
for (int i = 0; i < dtProjectStatus.Rows.Count; i++)
{
if (dtProjectStatus.Rows[i]["EndDate"].ToString() == string.Empty)
{
dtProjectStatus.Rows.RemoveAt(i);
dtProjectStatus.AcceptChanges();
i = -1;
}
}
Chart3.DataSource = dtProjectStatus;
Chart3.DataBind();
Chart3.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;
Chart3.ChartAreas["ChartArea1"].AxisY.MajorGrid.Enabled = false;
Chart1.DataSource = dtProjectStatus;
Chart1.DataBind();
Chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;
}
}
public void ProjectCompleted()
{
DataTable dtProjectCompleted = objBAL.ProjectCompleted();
if (dtProjectCompleted.Rows.Count > 0)
{
GridView4.DataSource = dtProjectCompleted;
GridView4.DataBind();
}
}
public void BDMDashboardDemo()
{
DataTable dtDemo = objBAL.BDMDashboardDemoBAL();
if (dtDemo.Rows.Count > 0)
{
Chart2.DataSource = dtDemo;
Chart2.DataBind();
Chart2.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;
Chart2.ChartAreas["ChartArea1"].AxisY.MajorGrid.Enabled = false;
}
}
推荐答案
Set Update mode of update panel as conditional like UpdateMode=\"Conditional\"
And each event set is UpdatePanel1.Update();
as per yours condition.
Set Update mode of update panel as conditional like UpdateMode="Conditional"
And each event set is UpdatePanel1.Update();
as per yours condition.
这篇关于更新面板没有工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!