首页 新闻 搜索 专区 学院

网页在ADSL上网状态下刷新太慢 ,会不会因为有4个DropDownList的影响

0
悬赏园豆:10 [已解决问题] 解决于 2012-10-24 19:44

我这个网页,如果用户是光纤,刷新速度还可以的,但是用户假如是ADSL的话,就明显慢了,对此我加入了ajax技术,但是依然慢, 不知道是不是因为网页上有4个DropDownList的影响.请大家帮忙看一下,如何修改,会快一点,并且光纤的与ADSL的速度相差如此之大,说明了什么呢

前台代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Qcount.aspx.cs" Inherits="Qc_Qcount" %>

<%@ Register src="../WebUserControl.ascx" tagname="WebUserControl" tagprefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title>大客户产品检验状况统计</title>
  <style type="text/css">
  .style3
  {
  text-align: center;
  font-size: x-large;
  }
  </style>
</head>
<body>
  <form id="form1" runat="server">
  <uc1:WebUserControl ID="WebUserControl1" runat="server" />
  <div>   
  </div>
  <div class="style3">
  大客户产品检验状况统计</div>
  <div>
  </div>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   
  <asp:ScriptManager ID="ScriptManager1" runat="server">
  </asp:ScriptManager>
  <asp:UpdatePanel ID="UpdatePanel1" runat="server">
  <ContentTemplate>   
  <div>
    
  <asp:UpdateProgress ID="UpdateProgress1" runat="server">
  <ProgressTemplate>
  正在操作中,请稍候
  </ProgressTemplate>
  </asp:UpdateProgress>
    
  <br />   
  &nbsp;<asp:Button ID="AB" runat="server" onclick="AB_Click" Text="新建"  
  Width="79px" />
  &nbsp;&nbsp;
  &nbsp;&nbsp;<asp:Button ID="AC" runat="server" Text="删除"  
  Width="79px" onclick="AC_Click" onclientclick="return confirm('是/否')" />
  &nbsp;&nbsp;
  </div>
  <div>
    
  <asp:Label ID="labid" runat="server"></asp:Label>
&nbsp;&nbsp;&nbsp;
  <asp:Label ID="Label1" runat="server" Text="*日期"></asp:Label>
  <asp:TextBox ID="txtga51" runat="server" Width="77px"></asp:TextBox>
  <asp:Label ID="Label2" runat="server" Text="*加工点"></asp:Label>
  <asp:DropDownList ID="txtga02" runat="server"   
  style="margin-top: 0px" Width="124px" AutoPostBack="True" onselectedindexchanged="txtga02_SelectedIndexChanged"  
  >
  </asp:DropDownList>
  <asp:Label ID="Label6" runat="server" Text="*流水线"></asp:Label>
  <asp:DropDownList ID="txtga03" runat="server"   
  style="margin-top: 0px" Width="150px"  
  >
  </asp:DropDownList>
  <asp:Label ID="Label3" runat="server" Text="*产品"></asp:Label>
  <asp:DropDownList ID="txtga01" runat="server"  
  Width="124px" AutoPostBack="True"  
  onselectedindexchanged="txtga01_SelectedIndexChanged">
  </asp:DropDownList>
  <asp:Label ID="Label4" runat="server" Text="*生产数量"></asp:Label>
  <asp:TextBox ID="txtga91" runat="server" Width="114px"></asp:TextBox>
  </div>
  <asp:Label ID="Label5" runat="server" Text="检验工序"></asp:Label>
  <asp:DropDownList ID="txtgb01" runat="server" AutoPostBack="True" Width="141px"  
  onselectedindexchanged="txtgb01_SelectedIndexChanged">
  </asp:DropDownList>
  <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"  
  Height="133px" onrowediting="GridView1_RowEditing"  
  onrowupdating="GridView1_RowUpdating" DataKeyNames="ID,gb01,gb02,gb03"  
  onrowcancelingedit="GridView1_RowCancelingEdit">
  <Columns>
  <asp:BoundField HeaderText="不良项目" DataField="gb04" />
  <asp:BoundField HeaderText="不良数量" DataField="gb92" />
  <asp:BoundField HeaderText="填写人" DataField="CreatePerson" />
  <asp:BoundField HeaderText="填写时间" DataField="CreatePersonDate" />
  <asp:CommandField ShowEditButton="True" />
  </Columns>
  </asp:GridView>
  </ContentTemplate>
  </asp:UpdatePanel>   
  </form>
</body>
</html>

后台代码如下:

public partial class Qc_Qcount : System.Web.UI.Page
{
  protected void Page_Load(object sender, EventArgs e)
  {
  if (!IsPostBack)
  {
  droplisttext();//下拉框的值
  Maticsoft.Model.AYONGHU mma = (Maticsoft.Model.AYONGHU)Session["ayonghu"];
  ViewState["name"] = mma.NAME;
  }
  }
  private void droplisttext()//改变下拉框的值
  {
  //求得下拉框的参数
  Maticsoft.BLL.Apm bll = new Maticsoft.BLL.Apm();
  DataTable idt;
  idt = bll.GetAllList().Tables[0];
  ViewState["dt"] = idt;
  //加工点
  DataView dv1 = new DataView(idt);
  dv1.RowFilter = ("parentcode='35'");
  txtga02.DataSource = dv1;
  txtga02.DataTextField = "cinvcname";
  txtga02.DataValueField = "no";
  txtga02.DataBind();
  txtga02.Items.Insert(0, new ListItem("", ""));
  txtga02.SelectedIndex = 0;
  //产品
  DataView dv2 = new DataView(idt);
  dv2.RowFilter = ("parentcode='3001'");
  txtga01.DataSource = dv2;
  txtga01.DataTextField = "cinvcname";
  txtga01.DataValueField = "no";
  txtga01.DataBind();
  //添加产品空白项   
  this.txtga01.Items.Insert(0, new ListItem("", ""));
  this.txtga01.SelectedIndex = 0;
  this.txtgb01.Items.Insert(0, new ListItem("", ""));
  this.txtgb01.SelectedIndex = 0;
  }

  protected void txtga01_SelectedIndexChanged(object sender, EventArgs e)//产品选择框
  {
  string ga51 = txtga51.Text.Trim();   
  string ga01value = txtga01.SelectedValue.ToString();
  string ga02value = txtga02.SelectedValue.ToString();
  string ga03value = txtga03.SelectedValue.ToString();
  //确认该记录是否已经存在有的话就返回值,
  //先做好参数
  SqlParameter[] parameters = {
new SqlParameter("@ga01", SqlDbType.VarChar,250),
new SqlParameter("@ga02", SqlDbType.VarChar,250),
new SqlParameter("@ga03", SqlDbType.VarChar,250),
new SqlParameter("@ga51", SqlDbType.DateTime)};
  parameters[0].Value = ga01value;
  parameters[1].Value = ga02value;
  parameters[2].Value = ga03value;
  parameters[3].Value = ga51;
  //执行存储过程
  SqlDataReader sReader = Maticsoft.DBUtility.DbHelperSQL.RunProcedure("Qcountifinsert", parameters);
  sReader.Read();
  labid.Text = sReader[0].ToString();//对ID赋值
  txtga91.Text = sReader[1].ToString(); //对数量赋值,如果已经存在,就会直接显示   
  sReader.Close();
  //生成产品
  DataTable dt = (DataTable)ViewState["dt"];
  DataView dv2 = new DataView(dt);
  dv2.RowFilter = ("parentcode='" + txtga01.SelectedValue.ToString() + "'");
  txtgb01.DataSource = dv2;
  txtgb01.DataTextField = "cinvcname";
  txtgb01.DataValueField = "no";
  txtgb01.DataBind();
  //添加工序空白项   
  this.txtgb01.Items.Insert(0, new ListItem("", ""));
  this.txtgb01.SelectedIndex = 0;

  }
  protected void txtgb01_SelectedIndexChanged(object sender, EventArgs e)//检验工序选择
  {
  //判断必填项
  if (ifempty())
  {
  return;
  }
  if (labid.Text.Length == 0)
  {
  MessageBox.Show(this, "ID号没有,无法生成记录");
  return;
  }
  string qcountid = labid.Text;//获取主表id号
  string gb01 = txtgb01.SelectedValue.ToString();//大工序编号
  string gb02 = txtgb01.SelectedItem.Text;   
  //建立共用变量
  ViewState["id"] = qcountid;
  ViewState["gb01"] = gb01;
  ViewState["gb02"] = gb02;   
  showdata();//获取数据源,刷新数据
  }
  protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
  {
  }
  protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
  {
  GridView1.EditIndex = e.NewEditIndex;
  showdata();
  }
  private void showdata()//刷新数据
  {
  SqlParameter[] parameters = {
new SqlParameter("@gb91", SqlDbType.Int),
new SqlParameter("@gb01", SqlDbType.VarChar,250),
new SqlParameter("@gb02", SqlDbType.VarChar,250)};
  parameters[0].Value = int.Parse(ViewState["id"].ToString());
  parameters[1].Value = ViewState["gb01"].ToString();
  parameters[2].Value = ViewState["gb02"].ToString();   
  //执行存储过程
  DataSet ds = Maticsoft.DBUtility.DbHelperSQL.RunProcedure("Qcountbinsert", parameters, "Qcountb");
  GridView1.DataSource = ds.Tables["Qcountb"].DefaultView;
  GridView1.DataBind();
  }
  protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
  {
  GridView1.EditIndex = -1;
  showdata();
  }
  protected void txtga02_SelectedIndexChanged(object sender, EventArgs e)
  {
  //流水线
  DataView dv2 = new DataView((DataTable)ViewState["dt"]);
  dv2.RowFilter = ("parentcode='" + txtga02.SelectedValue.ToString() + "'");
  txtga03.DataSource = dv2;
  txtga03.DataTextField = "cinvcname";
  txtga03.DataValueField = "no";
  txtga03.DataBind();
  }
  protected void AC_Click(object sender, EventArgs e)//删除
  {
  }
}

zhengyingcan的主页 zhengyingcan | 初学一级 | 园豆:12
提问于:2012-10-06 17:56
< >
分享
最佳答案
0

先找出慢的原因:

1:分析数据库查询时间,是不是查询的时间长,如果是,应该是你的语句有问题。

2:查询是不是生成的ViewState太大,如果是,用工具看返回的文本大小。

这种问题很简单,只要有点以经验和工具就可以了。

 

另外,操作数据库,试下用 CYQ.Data 框架,速度快,简单,方便,代码简洁。

收获园豆:10
路过秋天 | 老鸟四级 |园豆:4756 | 2012-10-06 22:55

查询时间并不长,因为光纤的客户端还是速度很快的,  ViewState是有点大,不过光纤的客户端不觉得慢,ADSL才觉得慢.

zhengyingcan | 园豆:12 (初学一级) | 2012-10-07 07:34
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册