Javascript实现GridView无刷新选择一行
用Javascript可以实现对GridView中某一行选择,而无需进行页面的刷新。
首先要在GridView的onrowdatabound的event handler中为GridView中的每一行onclick绑定event handler (Javascript)。假如GridView代码如下:
<asp:GridView runat="server" id="GridViewCategory" AutoGenerateColumns="False"
Width="100%" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid"
BorderWidth="3px" CellPadding="4" CellSpacing="2"
ForeColor="Black" onrowdatabound="GridViewCategory_RowDataBound">
<RowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="Description" HeaderText="Category" />
</Columns>
<FooterStyle BackColor="#CCCCCC" />
<PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
</asp:GridView>
onrowdatabound的event handler代码如下:
protected void GridViewCategory_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
&nbs
相关文档:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>JS调用现成Word模板完成打印</title>
<script type="text/javascript">
//转换word的函数
function ......
1.如何获取表单<select>域的选择部分的文本?
<form name="a">
<select name="a" size="1" onchange="_sel(this)">
<option value="a">1</option>
<option value="b">2</option>
<option value="c">3</option>
</select>
</form&g ......
设为首页和添加收藏的Javascript代码,兼容性还可以,各种主流浏览器都测试通过了。
function addfavorite(){//加入收藏
if (document.all){
window.external.addFavorite("http://"+document.location.host+"/",document.title);
}else if (window.sidebar){
window.sidebar.addPanel(document.tit ......
在javascript中,对象实际上就是一个哈希表,比如下面这个user对象:
function user(n, a)
{
this.name = n;
this.age = a;
this.toString = function() {
return "Name:" + this.name + ", Age:" + this.age;
}
}
var u = new user("tom", 18);
for (var k in u) {
alert('key: ' ......
<html>
<body>
<script type="text/JScript">
for (i=0; i<10000; i++) { // this loop enforces the effect
var model = new Object();
var element = document.createElement("<br>");
model.myElement = ......