这是我加载一个页面的代码
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!IsPostBack)BindGrid();
}
public void BindGrid()
{
//连接数据库
string strconn = ConfigurationSettings.AppSettings["dns"];
SqlConnection cn = new SqlConnection(strconn);
//创建SQL对象,调用视图
SqlDataAdapter da = new SqlDataAdapter("zhigonglist",cn);
//创建并填充DataSet
DataSet ds = new DataSet();
da.Fill(ds);
zhigonglist.DataSource = ds.Tables[0].DefaultView;
zhigonglist.DataBind();
cn.Close();
}
不知道怎么会事,登陆到这个页面时出现一个aspnet_awp.exe进程,使CPU达到100%,这个页面也无法打开。然后电脑运行很慢。原来不会出现这种情况,请问这是怎么会事,有解决的办法没?
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!IsPostBack)BindGrid();
}
public void BindGrid()
{
//连接数据库
string strconn = ConfigurationSettings.AppSettings["dns"];
SqlConnection cn = new SqlConnection(strconn);
//创建SQL对象,调用视图
SqlDataAdapter da = new SqlDataAdapter("zhigonglist",cn);
//创建并填充DataSet
DataSet ds = new DataSet();
da.Fill(ds);
zhigonglist.DataSource = ds.Tables[0].DefaultView;
zhigonglist.DataBind();
cn.Close();
}
不知道怎么会事,登陆到这个页面时出现一个aspnet_awp.exe进程,使CPU达到100%,这个页面也无法打开。然后电脑运行很慢。原来不会出现这种情况,请问这是怎么会事,有解决的办法没?
解决方案 »
- repeater怎么使用
- 请问如何将所有HTML标签变为空格?
- 小弟初学,请问怎么样实现下面所说的功能?
- asp.net框架页权项控制问题,很奇怪请高手支招.
- 该程序在 vs下是可以运行,发布到iis上就会出这个错!请问各位怎么解决??
- 请问用winform 可不可以写一个c/s架构的网络OA?
- 把我吓坏了,执行20多次删除操作后,出现ORA-00020: maximum number of processes () exceeded ?不知这是什么原因引起的。如何解决呢?
- .net求教怎么一打开评论页面,就定位到那条想看的内容中
- 关于动态添加的问题
- 关于在xml解决长文本换行的问题,有源码.但还有一点问题,请高手帮忙
- 求SQL语句.技术要求时间函数`救命啊!!!!!!!!!!
- 请朋友们指教 !
达到100%
可能是你的存储过程“zhigonglist”有什么问题,不知道写了什么
SqlDataAdapter da = new SqlDataAdapter("zhigonglist",cn);应该是这得问题:
还有:da.Fill(ds);---改成:da.Fill(ds,"zhigonglist");
Create porc proc_system_filter
(
@SQLEx varchar(1000)
)
as
begin
declare @strSQL varchar(2000);
set @strSQL='SELECT * FROM VIEW_SYSTEM_FILTER WHERE(1>0)' if(@SQLEx is not null and rtrim(ltrim(@SQLEx))<>'' and @SQLEx<>'')
begin
@strSQL=@strSQL+@SQLEx;
end
exec(@strSQL);
end
//*****数据调用
private void LoadDataBind()
{
SqlCommand sqlcom=new sqlcommand("proc_system_filter",sqlcon);
sqlcom.comandtype=commandtype.sorteproducted; sqlcom.paramter.add(new sqlparamter("@SQLEx",sqldbtype.varchar,100));
sqlcom.paramter["@SQLEx"].value=txtsql.text;
--拆行命令
sqldataapter sqlapter=sqlcom.executereader();
DGRid.datasource=sqlapter;
DGRid.databind();}
hunter_32,要打什么样的补丁!
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.Common;
using System.Data.SqlClient;
using System.Configuration;namespace news.page
{
/// <summary>
/// gengxin 的摘要说明。
/// </summary>
public class gengxin : System.Web.UI.Page
{
protected System.Web.UI.HtmlControls.HtmlForm Form1;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.DataGrid zhigonglist;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!IsPostBack)BindGrid();
}
public void BindGrid()
{
//连接数据库
string strconn = ConfigurationSettings.AppSettings["dns"];
SqlConnection cn = new SqlConnection(strconn);
//创建SQL对象,调用视图
SqlDataAdapter da = new SqlDataAdapter("zhigonglist1",cn);
//创建并填充DataSet
DataSet ds = new DataSet();
da.Fill(ds,"zhigonglist1");
zhigonglist.DataSource = ds.Tables[0].DefaultView;
zhigonglist.DataBind();
cn.Close();
}
private void zhigonglist_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
this.zhigonglist.CurrentPageIndex = e.NewPageIndex;
BindGrid();
} private void Button1_Click(object sender, System.EventArgs e)
{
Response.Redirect("add.aspx");
} private void zhigonglist_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
//从文件WEB。CONFIG中读连接字符串
string strconn = ConfigurationSettings.AppSettings["dns"];
//连接数据库TSGL
SqlConnection cn = new SqlConnection(strconn);
cn.Open();
string zhigongdelete = "delete from zhigong where id=@id";
SqlCommand cm = new SqlCommand(zhigongdelete,cn);
cm.Parameters.Add("@id",SqlDbType.Int);
//从DATEGRID中取得更新内容,Cell[1]为UID列
string bidvalue = e.Item.Cells[0].Text.ToString();
cm.Parameters["@id"].Value = bidvalue;
try
{
cm.ExecuteNonQuery();
}
catch(Exception fa)
{
Response.Write(fa.Message.ToString());
}
zhigonglist.EditItemIndex = -1;
BindGrid();
Response.Write("<script language='javascript'>alert('删除成功');</script>");
} private void zhigonglist_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
{
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
//删除确认
LinkButton delBttn = (LinkButton) e.Item.Cells[10].Controls[0];
HyperLink nameHlk = (HyperLink) e.Item.Cells[2].Controls[1];
delBttn.Attributes.Add("onclick","javascript:return confirm('确定删除" + nameHlk.Text + "?');");
//颜色交替
e.Item.Attributes.Add("onmouseover","this.style.backgroundColor='seashell'");
if(e.Item.ItemType == ListItemType.Item)
{
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='#ffffff'");
} if(e.Item.ItemType ==ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='seashell'");
}
}
this.zhigonglist.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.zhigonglist_ItemDataBound);
}
}
}
}
我把后台贴出来了,大家帮我看看是不是死循环?请各位高手帮帮忙啊!!!