创建一个界面,里有一个GRIDVIEW1和button1第一次进入页面的时候好用.可以固定住表头.进入后,如果我点BUTTON1执行一条SELECT * FROM TABLE1的语句后,重新绑定GRIDVIEW1的数据源后,
表头固定就不好用了.看了一下代码,主要是下面的WINDWOS.onload 这块控制的.在窗口读入时执行.
但是点BUTTON1时并没有重新对窗口进行ONLOAD,请问各位高手如何解决呀???谢谢!!孟子文章的地址:
http://dotnet.aspx.cc/article/7919da6b-9014-41c2-b9b6-10e5ec047f7d/read.aspx
<script type="text/javascript">
function s()
{ var t = document.getElementById("<%=GridView1.ClientID%>");
var t2 = t.cloneNode(true)
for(i = t2.rows.length -1;i > 0;i--)
t2.deleteRow(i)
t.deleteRow(0)
a.appendChild(t2)
}
window.onload = s
</script>
button1代码:
string conString = System.Configuration.ConfigurationManager.ConnectionStrings["aa"].ConnectionString;
///创建连接
SqlConnection connection = new SqlConnection(conString);
SqlCommand command = new SqlCommand();
command.Connection = connection;
command.CommandType = CommandType.Text;
command.CommandText = "select * from table1";
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataTable data = new DataTable();
adapter.Fill(data);
int pagerow = 2;
int numrow = 0; int allrow = data.Rows.Count;
if (allrow > pagerow)
{
numrow = allrow % pagerow; for (int i = 0; i <= pagerow - numrow - 1; i++)
{
DataRow dr = data.NewRow();//添加新行
data.Rows.InsertAt(dr, data.Rows.Count);//指定添加行位置
}
}
else
{
numrow = pagerow - allrow; for (int i = 0; i <= numrow - 1; i++)
{
DataRow dr = data.NewRow();//添加新行
data.Rows.InsertAt(dr, data.Rows.Count);///
}
} GridView6.DataSource = data;
// GridView1.PageIndex = pageIndex;//设置当前显示第几页
GridView6.DataBind();
执行上述代码后并不能触发WINDOWS.ONLOAD,请问这块改成什么可以使用呀??????
表头固定就不好用了.看了一下代码,主要是下面的WINDWOS.onload 这块控制的.在窗口读入时执行.
但是点BUTTON1时并没有重新对窗口进行ONLOAD,请问各位高手如何解决呀???谢谢!!孟子文章的地址:
http://dotnet.aspx.cc/article/7919da6b-9014-41c2-b9b6-10e5ec047f7d/read.aspx
<script type="text/javascript">
function s()
{ var t = document.getElementById("<%=GridView1.ClientID%>");
var t2 = t.cloneNode(true)
for(i = t2.rows.length -1;i > 0;i--)
t2.deleteRow(i)
t.deleteRow(0)
a.appendChild(t2)
}
window.onload = s
</script>
button1代码:
string conString = System.Configuration.ConfigurationManager.ConnectionStrings["aa"].ConnectionString;
///创建连接
SqlConnection connection = new SqlConnection(conString);
SqlCommand command = new SqlCommand();
command.Connection = connection;
command.CommandType = CommandType.Text;
command.CommandText = "select * from table1";
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataTable data = new DataTable();
adapter.Fill(data);
int pagerow = 2;
int numrow = 0; int allrow = data.Rows.Count;
if (allrow > pagerow)
{
numrow = allrow % pagerow; for (int i = 0; i <= pagerow - numrow - 1; i++)
{
DataRow dr = data.NewRow();//添加新行
data.Rows.InsertAt(dr, data.Rows.Count);//指定添加行位置
}
}
else
{
numrow = pagerow - allrow; for (int i = 0; i <= numrow - 1; i++)
{
DataRow dr = data.NewRow();//添加新行
data.Rows.InsertAt(dr, data.Rows.Count);///
}
} GridView6.DataSource = data;
// GridView1.PageIndex = pageIndex;//设置当前显示第几页
GridView6.DataBind();
执行上述代码后并不能触发WINDOWS.ONLOAD,请问这块改成什么可以使用呀??????
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货