删除数据以后!页面想没用css一样 页面上有一个datagrid 当我从datagrid里面删除一条数据以后,页面上想没加载css一样,当页面数据东西的时候css样式也会变。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 页面是不是有Response.Write()一段js。。 using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class admin_cus_manage_attorn_manage : System.Web.UI.Page{ private static int intRecordCount; //记录总数 private static int intPageCount; //总页数 private static int intCurrentPageIndex; //当前页码 private DataView dv; public string del_strsql; protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { LinkButton1.Text = "首页"; LinkButton2.Text = "上一页"; LinkButton3.Text = "下一页"; LinkButton4.Text = "尾页"; //将当前页面置为1,即显示第一页的记录 intCurrentPageIndex = 1; //设置属性 // DataGrid1.AllowPaging = "True"; DataGrid1.AllowPaging = true; // DataGrid1AllowCustomPaging = "True"; DataGrid1.AllowCustomPaging = true; //绑定数据(Bind()是一个自定义方法) this.Bind(intCurrentPageIndex); Response.Write("adfasfdsad"); } } private void Bind(int intCurrentPageIndex) { string strConn = ConfigurationSettings.AppSettings["Str_sql"].ToString(); //每次只取出一页(即10条)数据的SQL语句 string strSql = "select top 10 * from attorn where Attorn_id not in (select top " + (intCurrentPageIndex - 1) * 10 + " attorn_id from attorn order by attorn_id desc) order by attorn_id desc"; if (TextBox1.Text != null && TextBox1.Text != "") { strSql = "select top 10 * from attorn where attorn_id not in (select top " + (intCurrentPageIndex - 1) * 10 + " attorn_id from attorn where " + DropDownList1.SelectedValue + " like '%" + TextBox1.Text + "%' order by attorn_id desc) and " + DropDownList1.SelectedValue + " like '%" + TextBox1.Text + "%' order by attorn_id desc"; } //得到总记录数的SQL语句 string strSqlCount = "select count(*) from attorn "; if (TextBox1.Text != null && TextBox1.Text != "") { strSqlCount = "select count(*) from attorn where " + DropDownList1.SelectedValue + " like '%" + TextBox1.Text + "%'"; } //建立与数据的连接 SqlConnection dbConnection = new SqlConnection(strConn); dbConnection.Open(); //创建适配器的实例,并填充数据 SqlDataAdapter dsAdapter = new SqlDataAdapter(strSql, dbConnection); DataSet ds = new DataSet(); dsAdapter.Fill(ds); dv = ds.Tables[0].DefaultView; //取得总记录数 SqlCommand cmd = new SqlCommand(strSqlCount, dbConnection); intRecordCount = (Int32)cmd.ExecuteScalar(); //关闭连接 dbConnection.Close(); //计算总页数 double dblRecordCount; dblRecordCount = System.Convert.ToDouble(intRecordCount); intPageCount = (Int32)Math.Ceiling(dblRecordCount / 10); Label1.Text = intCurrentPageIndex.ToString(); Label2.Text = intPageCount.ToString(); //绑定数据 DataGrid1.DataSource = dv; DataGrid1.DataBind(); } protected void Button1_Click(object sender, EventArgs e) { intCurrentPageIndex = 1; //重新绑定数据 this.Bind(intCurrentPageIndex); } protected void Button2_Click(object sender, EventArgs e) { del_strsql = "delete attorn where Attorn_id= "; DelShanchu del_business = new DelShanchu(DataGrid1, del_strsql); intCurrentPageIndex = 1; //重新绑定数据 this.Bind(intCurrentPageIndex); } protected void LinkButton1_Click(object sender, EventArgs e) { intCurrentPageIndex = 1; //重新绑定数据 this.Bind(intCurrentPageIndex); } protected void LinkButton2_Click(object sender, EventArgs e) { intCurrentPageIndex = intCurrentPageIndex - 1; if (intCurrentPageIndex <= 0) { intCurrentPageIndex = 1; } //重新绑定数据 this.Bind(intCurrentPageIndex); } protected void LinkButton3_Click(object sender, EventArgs e) { intCurrentPageIndex = intCurrentPageIndex + 1; if (intCurrentPageIndex > intPageCount) { intCurrentPageIndex = intPageCount; } //重新绑定数据 this.Bind(intCurrentPageIndex); } protected void LinkButton4_Click(object sender, EventArgs e) { intCurrentPageIndex = intPageCount; //重新绑定数据 this.Bind(intCurrentPageIndex); }} <%@ Page Language="C#" AutoEventWireup="true" CodeFile="attorn_manage.aspx.cs" Inherits="admin_cus_manage_attorn_manage" %><!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 id="Head1" runat="server"> <title>YY3721后台管理</title> <link href="../style/sys_cus.css" rel="stylesheet" type="text/css"><style type="text/css"><!--body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px;}--></style> <script type="text/javascript"> function selectChk(flag) { var element; var i; element = document.all; if(flag) { for(i = 0;i < element.length;i ++) { if(element[i].tagName == "INPUT" && element[i].type == "checkbox") { element[i].checked = true; } } } else { for(i = 0;i < element.length;i ++) { if(element[i].tagName == "INPUT" && element[i].type == "checkbox") { element[i].checked = false; } } } }</script></head><body> <form id="form1" runat="server" action="attorn_manage.aspx"> <div> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td valign="top" style="width: 652px; height: 553px;"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="2" bgcolor="#2e6761" style="width: 671px"></td> </tr> <tr> <td height="20" bgcolor="#baddd9" style="width: 671px"> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="cus_button"> <tr> <td width="23%" height="28" align="right">请选择查询条件:</td> <td align="left" style="width: 27%"> <asp:DropDownList ID="DropDownList1" runat="server" Width="87px"> <asp:ListItem Value="[User_name]">会员名称</asp:ListItem> <asp:ListItem Value="Attorn_name">产品名称</asp:ListItem> <asp:ListItem Value="Attorn_company">公司名称</asp:ListItem> </asp:DropDownList> </td> <td width="20%" align="right">请输入关键字:</td> <td width="16%" align="right"> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td> <td width="20%" align="center"> <asp:Button ID="Button1" runat="server" Text="搜 索" OnClick="Button1_Click" /></td> </tr> </table> </td> </tr> <tr> <td height="468" align="center" valign="top" bgcolor="#ddeded" style="width: 671px"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="10" style="width: 669px"></td> </tr> </table> <table width="98%" border="0" cellpadding="0" cellspacing="1" bgcolor="#5CB1A7" class="cus_button"> <tr> <td colspan="7" align="center" bgcolor="#33887B" class="STYLE1" style="width: 100%; height: 26px"> 新药管理列表</td> </tr> <tr> <td bgcolor="#eaf4f4" colspan="7" rowspan="5" style="width: 100%; height: 275px" valign="top"> <asp:DataGrid ID="DataGrid1" runat="server" AllowPaging="True" AutoGenerateColumns="False" Width="100%"> <PagerStyle Visible="False" /> <Columns> <asp:HyperLinkColumn DataTextField="Attorn_name" HeaderText="产品名称" DataNavigateUrlField="Attorn_id" DataNavigateUrlFormatString="attorn_edit.aspx?Attorn_id={0}"></asp:HyperLinkColumn> <asp:BoundColumn DataField="User_name" HeaderText="会员名称"></asp:BoundColumn> <asp:BoundColumn DataField="Attorn_company" HeaderText="公司名称"></asp:BoundColumn> <asp:BoundColumn DataField="Attorn_authentication" HeaderText="是否认证"></asp:BoundColumn> <asp:BoundColumn DataField="Attorn_issuance" HeaderText="发布时间"></asp:BoundColumn> <asp:TemplateColumn HeaderText="选择"> <ItemTemplate> <asp:CheckBox ID="CheckBox1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"Attorn_id")%>' /> </ItemTemplate> </asp:TemplateColumn> </Columns> </asp:DataGrid></td> </tr> <tr> </tr> <tr> </tr> <tr> </tr> <tr> </tr> </table> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="cus_button"> <tr> <td colspan="3" align="center"> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label> <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">LinkButton</asp:LinkButton> <asp:LinkButton ID="LinkButton2" runat="server" OnClick="LinkButton2_Click">LinkButton</asp:LinkButton> <asp:LinkButton ID="LinkButton3" runat="server" OnClick="LinkButton3_Click">LinkButton</asp:LinkButton> <asp:LinkButton ID="LinkButton4" runat="server" OnClick="LinkButton4_Click">LinkButton</asp:LinkButton> </td> </tr> <tr> <td colspan="3" style="height: 24px" align="center"> <asp:Button ID="Button2" runat="server" Text="删 除" OnClick="Button2_Click" /> <input id="Button4" type="button" value="全 选" language="javascript" onclick="selectChk(true)" /> <input id="Button5" type="button" value="取 消" language ="javascript" onclick="selectChk(false)" /> </td> </tr> </table> </td> </tr> </table></td> </tr> </table> </div> </form></body></html> 还有一点就是~! 我在Page_Load里面让它response.write("ddd");如果这样的话他也会变。 又来发帖了,熟悉发送smtp邮件 c#中web.config的权限控制如何应用 急啊,请专家指导!关于不扩展类System.Web.UI.Page,因此此处不允许。 》》》100分求一个能够运行的,有注释的Neat Upload应用例子 .NET实现发表一条微博信息,同时跳到指定页面 新手求助!在线急等! 好烦人的问题哦 ! 一个发布公告得东东!!怎样做比较省资源阿?? ASP.net2.0 能否用Bind()把多个控件一个数据库字段绑定? SoundInTheory.DynamicImage 官网链接是什么啊 求一个简单的文本输入正则代码。 求救!关于语句写在哪的问题
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;public partial class admin_cus_manage_attorn_manage : System.Web.UI.Page
{ private static int intRecordCount; //记录总数
private static int intPageCount; //总页数
private static int intCurrentPageIndex; //当前页码
private DataView dv;
public string del_strsql;
protected void Page_Load(object sender, EventArgs e)
{ if (!Page.IsPostBack)
{ LinkButton1.Text = "首页";
LinkButton2.Text = "上一页";
LinkButton3.Text = "下一页";
LinkButton4.Text = "尾页"; //将当前页面置为1,即显示第一页的记录
intCurrentPageIndex = 1;
//设置属性
// DataGrid1.AllowPaging = "True";
DataGrid1.AllowPaging = true;
// DataGrid1AllowCustomPaging = "True";
DataGrid1.AllowCustomPaging = true; //绑定数据(Bind()是一个自定义方法)
this.Bind(intCurrentPageIndex);
Response.Write("adfasfdsad");
} }
private void Bind(int intCurrentPageIndex)
{
string strConn = ConfigurationSettings.AppSettings["Str_sql"].ToString();
//每次只取出一页(即10条)数据的SQL语句
string strSql = "select top 10 * from attorn where Attorn_id not in (select top " + (intCurrentPageIndex - 1) * 10 + " attorn_id from attorn order by attorn_id desc) order by attorn_id desc"; if (TextBox1.Text != null && TextBox1.Text != "")
{ strSql = "select top 10 * from attorn where attorn_id not in (select top " + (intCurrentPageIndex - 1) * 10 + " attorn_id from attorn where " + DropDownList1.SelectedValue + " like '%" + TextBox1.Text + "%' order by attorn_id desc) and " + DropDownList1.SelectedValue + " like '%" + TextBox1.Text + "%' order by attorn_id desc";
}
//得到总记录数的SQL语句
string strSqlCount = "select count(*) from attorn ";
if (TextBox1.Text != null && TextBox1.Text != "")
{
strSqlCount = "select count(*) from attorn where " + DropDownList1.SelectedValue + " like '%" + TextBox1.Text + "%'";
}
//建立与数据的连接
SqlConnection dbConnection = new SqlConnection(strConn);
dbConnection.Open();
//创建适配器的实例,并填充数据
SqlDataAdapter dsAdapter = new SqlDataAdapter(strSql, dbConnection);
DataSet ds = new DataSet();
dsAdapter.Fill(ds);
dv = ds.Tables[0].DefaultView; //取得总记录数 SqlCommand cmd = new SqlCommand(strSqlCount, dbConnection);
intRecordCount = (Int32)cmd.ExecuteScalar(); //关闭连接
dbConnection.Close(); //计算总页数
double dblRecordCount;
dblRecordCount = System.Convert.ToDouble(intRecordCount);
intPageCount = (Int32)Math.Ceiling(dblRecordCount / 10); Label1.Text = intCurrentPageIndex.ToString();
Label2.Text = intPageCount.ToString();
//绑定数据
DataGrid1.DataSource = dv;
DataGrid1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{ intCurrentPageIndex = 1; //重新绑定数据 this.Bind(intCurrentPageIndex); } protected void Button2_Click(object sender, EventArgs e)
{
del_strsql = "delete attorn where Attorn_id= ";
DelShanchu del_business = new DelShanchu(DataGrid1, del_strsql);
intCurrentPageIndex = 1; //重新绑定数据 this.Bind(intCurrentPageIndex); }
protected void LinkButton1_Click(object sender, EventArgs e)
{ intCurrentPageIndex = 1; //重新绑定数据
this.Bind(intCurrentPageIndex);
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
intCurrentPageIndex = intCurrentPageIndex - 1;
if (intCurrentPageIndex <= 0)
{
intCurrentPageIndex = 1;
}
//重新绑定数据
this.Bind(intCurrentPageIndex);
}
protected void LinkButton3_Click(object sender, EventArgs e)
{
intCurrentPageIndex = intCurrentPageIndex + 1;
if (intCurrentPageIndex > intPageCount)
{
intCurrentPageIndex = intPageCount;
}
//重新绑定数据
this.Bind(intCurrentPageIndex); }
protected void LinkButton4_Click(object sender, EventArgs e)
{
intCurrentPageIndex = intPageCount;
//重新绑定数据
this.Bind(intCurrentPageIndex);
}
}
<head id="Head1" runat="server">
<title>YY3721后台管理</title>
<link href="../style/sys_cus.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}-->
</style> <script type="text/javascript">
function selectChk(flag)
{
var element;
var i;
element = document.all;
if(flag)
{
for(i = 0;i < element.length;i ++)
{
if(element[i].tagName == "INPUT" && element[i].type == "checkbox")
{
element[i].checked = true;
}
}
}
else
{
for(i = 0;i < element.length;i ++)
{
if(element[i].tagName == "INPUT" && element[i].type == "checkbox")
{
element[i].checked = false;
}
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server" action="attorn_manage.aspx">
<div>
<table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr>
<td valign="top" style="width: 652px; height: 553px;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="2" bgcolor="#2e6761" style="width: 671px"></td>
</tr>
<tr>
<td height="20" bgcolor="#baddd9" style="width: 671px">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="cus_button">
<tr>
<td width="23%" height="28" align="right">请选择查询条件:</td>
<td align="left" style="width: 27%">
<asp:DropDownList ID="DropDownList1" runat="server" Width="87px">
<asp:ListItem Value="[User_name]">会员名称</asp:ListItem>
<asp:ListItem Value="Attorn_name">产品名称</asp:ListItem>
<asp:ListItem Value="Attorn_company">公司名称</asp:ListItem>
</asp:DropDownList> </td>
<td width="20%" align="right">请输入关键字:</td>
<td width="16%" align="right">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td>
<td width="20%" align="center">
<asp:Button ID="Button1" runat="server" Text="搜 索" OnClick="Button1_Click" /></td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="468" align="center" valign="top" bgcolor="#ddeded" style="width: 671px"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="10" style="width: 669px"></td>
</tr>
</table>
<table width="98%" border="0" cellpadding="0" cellspacing="1" bgcolor="#5CB1A7" class="cus_button"> <tr>
<td colspan="7" align="center" bgcolor="#33887B" class="STYLE1" style="width: 100%; height: 26px">
新药管理列表</td>
</tr>
<tr>
<td bgcolor="#eaf4f4" colspan="7" rowspan="5" style="width: 100%; height: 275px"
valign="top">
<asp:DataGrid ID="DataGrid1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
Width="100%">
<PagerStyle Visible="False" />
<Columns>
<asp:HyperLinkColumn DataTextField="Attorn_name" HeaderText="产品名称" DataNavigateUrlField="Attorn_id" DataNavigateUrlFormatString="attorn_edit.aspx?Attorn_id={0}"></asp:HyperLinkColumn>
<asp:BoundColumn DataField="User_name" HeaderText="会员名称"></asp:BoundColumn>
<asp:BoundColumn DataField="Attorn_company" HeaderText="公司名称"></asp:BoundColumn>
<asp:BoundColumn DataField="Attorn_authentication" HeaderText="是否认证"></asp:BoundColumn>
<asp:BoundColumn DataField="Attorn_issuance" HeaderText="发布时间"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="选择">
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"Attorn_id")%>' />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid></td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="cus_button">
<tr>
<td colspan="3" align="center">
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">LinkButton</asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" OnClick="LinkButton2_Click">LinkButton</asp:LinkButton>
<asp:LinkButton ID="LinkButton3" runat="server" OnClick="LinkButton3_Click">LinkButton</asp:LinkButton>
<asp:LinkButton ID="LinkButton4" runat="server" OnClick="LinkButton4_Click">LinkButton</asp:LinkButton>
</td>
</tr>
<tr>
<td colspan="3" style="height: 24px" align="center">
<asp:Button ID="Button2" runat="server" Text="删 除" OnClick="Button2_Click" />
<input id="Button4" type="button" value="全 选" language="javascript" onclick="selectChk(true)" />
<input id="Button5" type="button" value="取 消" language ="javascript" onclick="selectChk(false)" /> </td>
</tr>
</table>
</td>
</tr>
</table></td>
</tr>
</table>
</div>
</form>
</body>
</html>
我在Page_Load里面让它response.write("ddd");
如果这样的话他也会变。