刷新Main gridview内部网格时正在关闭

时间:2014-05-05 10:40:27

标签: c# asp.net gridview

在asp.net中,我们能够在网格(内部网格)中绑定Grid。我需要每30秒刷新一次主网格和内部网格,同时刷新网格,我之前打开的内部网格已关闭。他们需要打开刷新数据后打开的内部网格。

我们已使用asp:Timer控件,在OnTick事件中,我们再次将数据绑定到网格。

任何人都可以为我提供任何解决方案。

.aspx页面中的代码

<img alt="" style="cursor: pointer" src="Images/plus.png" />

                                           

            <asp:Panel ID="pnlAgents" runat="server" Visible="false">
                <asp:GridView ID="gvAgentStatus" runat="server" AutoGenerateColumns="false" CssClass="ChildGrid">
                    <Columns>
                        <asp:BoundField ItemStyle-Width="150px" DataField="AgentSip" HeaderText="Agent Sip" />
                        <asp:BoundField ItemStyle-Width="150px" DataField="Presence" HeaderText="Presence" />
                        <asp:BoundField ItemStyle-Width="150px" DataField="agReceived" HeaderText=" Answered" />
                        <asp:BoundField ItemStyle-Width="150px" DataField="agIgnored" HeaderText=" Unanswered" />
                        <asp:BoundField ItemStyle-Width="150px" DataField="agDialed" HeaderText=" Dialled" />
                        <asp:BoundField ItemStyle-Width="150px" DataField="agVoiceMail" HeaderText="VoiceMail" />
                    </Columns>
                </asp:GridView>
            </asp:Panel>
        </ItemTemplate>
    </asp:TemplateField>
    <asp:BoundField ItemStyle-Width="150px" DataField="JobNum" HeaderText="Job Number" />
    <asp:BoundField ItemStyle-Width="150px" DataField="Total" HeaderText="Call Received" />
    <asp:BoundField ItemStyle-Width="150px" DataField="Success" HeaderText=" Answered" />
    <asp:BoundField ItemStyle-Width="150px" DataField="Ignored" HeaderText=" Unanswered" />
    <asp:BoundField ItemStyle-Width="150px" DataField="Dialed" HeaderText=" Dialled" />
    <asp:BoundField ItemStyle-Width="150px" DataField="UnSuccess" HeaderText="UnSuccess" />
    <asp:BoundField ItemStyle-Width="150px" DataField="VoiceMail" HeaderText="VoiceMail" />
</Columns>

脚本功能

$("[src*=plus]").live("click", function () {            
    $(this).closest("tr").after("<tr><td></td><td colspan = '999'>" + $(this).next().html() + "</td></tr>")
    $(this).attr("src", "Images/minus.png");
});
$("[src*=minus]").live("click", function () {
    $(this).attr("src", "Images/plus.png");
    $(this).closest("tr").next().remove();
});

在aspx.cs文件中

绑定主网格

 SqlParameter[] _paramJob = new SqlParameter[1];
_paramJob[0] = new SqlParameter("@Date", txtDate.Text);
DataSet _dsJobStat = DataAccess.ExecuteDataAdapter(SqlConnectionStr.con, "klac_QueueStatus", _paramJob);

gvJobStatus.DataSource = _dsJobStat;
gvJobStatus.DataBind();

在gvJobStatus_RowDataBound

中绑定内部网格
protected void gvJobStatus_RowDataBound(object sender, GridViewRowEventArgs e)
{
    string cJobNumId = gvJobStatus.DataKeys[e.Row.RowIndex].Value.ToString();
    GridView gvAgentStatus = e.Row.FindControl("gvAgentStatus") as GridView;

    SqlParameter[] _paramAgentStat = new SqlParameter[2];
    _paramAgentStat[0] = new SqlParameter("@Date", txtDate.Text);
    _paramAgentStat[1] = new SqlParameter("@JobNum", cJobNumId);

    DataSet _dsAgentStats = DataAccess.ExecuteDataAdapter(SqlConnectionStr.con, "klac_QueueAgentStatus", _paramAgentStat);

    List<CallStatistics> _objCallAgentList = new List<CallStatistics>();
    for (int i = 0; i < _dsAgentStats.Tables[0].Rows.Count; i++)
    {
        CallStatistics obj = new CallStatistics();

        obj.AgentSip = _dsAgentStats.Tables[0].Rows[i]["AgentSip"] == DBNull.Value ? "" : _dsAgentStats.Tables[0].Rows[i]["AgentSip"].ToString();

        string _Sip = string.Empty;

        if (obj.AgentSip != "")
        {
            if (obj.AgentSip.IndexOf(":") > 0)
            {
                string[] _agent = obj.AgentSip.Split(':');
                _Sip = _agent[1];
            }
            else
                _Sip = obj.AgentSip;

            SqlParameter[] presenceparam = new SqlParameter[1];
            presenceparam[0] = new SqlParameter("@_Publisher", _Sip);
            DataSet _dsPresence = DataAccess.ExecuteDataAdapter(SqlConnectionStr._LyncCon, "DiagShowPublisherPresence", presenceparam);

            string source = _dsPresence.Tables[1].Rows[1]["Data"].ToString().Replace(@"""", @"\""");
            string[] stringSeparators = new string[] { "<availability>", "</availability>" };
            string[] result;

            result = source.Split(stringSeparators,
                            StringSplitOptions.RemoveEmptyEntries);

            obj.Presence = Presence(Convert.ToInt32(result[1]));
        }
        else
        {
            _Sip = obj.AgentSip;
            obj.Presence = "Unknown";
        }


        obj.agDialed = _dsAgentStats.Tables[0].Rows[i]["Dialed"] == DBNull.Value ? 0 : Convert.ToInt32(_dsAgentStats.Tables[0].Rows[i]["Dialed"].ToString());
        obj.agReceived = _dsAgentStats.Tables[0].Rows[i]["Success"] == DBNull.Value ? 0 : Convert.ToInt32(_dsAgentStats.Tables[0].Rows[i]["Success"].ToString());
        obj.agVoiceMail = _dsAgentStats.Tables[0].Rows[i]["VoiceMail"] == DBNull.Value ? 0 : Convert.ToInt32(_dsAgentStats.Tables[0].Rows[i]["VoiceMail"].ToString());
        obj.agIgnored = _dsAgentStats.Tables[0].Rows[i]["Ignored"] == DBNull.Value ? 0 : Convert.ToInt32(_dsAgentStats.Tables[0].Rows[i]["Ignored"].ToString());

        _objCallAgentList.Add(obj);
    }

    gvAgentStatus.DataSource = _objCallAgentList;
    gvAgentStatus.DataBind();
}

0 个答案:

没有答案