关于GridView
2016-03-21 10:46
337 查看
//—————————————————新增总结————————————————————
1.GridView的多选效果(注意一个字都不要错才能运行)
(1)先在JavaScript中写代码:
<head runat="server">
<script
language="javascript">
function GetAllCheckBox(CheckAll)
{
var items=document.getElementsByTagName_r("input");
for(i=0;i<items.length;i++)
{
if(items[i].type=="checkbox")
{
items[i].checked=CheckAll.checked;
}
}
}
</script>
<title>无标题页</title>
(2)在控件的onclick事件中写代码(即使控件没有这个事件,也要硬写上去)
<asp:CheckBox ID="chkCheckAll" runat="server"
Text="全选"
onclick="javascript:GetAllCheckBox(this)"/>
2.GridView的光棒效果:——要在它的行绑定事件中写:里面注释的即是。
//GridView的行绑定事件
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState
== DataControlRowState.Alternate)
{
//关于多选框
CheckBox box =
(CheckBox)e.Row.Cells[7].FindControl("CboxSelect");
if (MessageManager.IDList != null)
{
if (MessageManager.IDList.Contains( box.Text))
{
box.Checked =
true;
}
}
//为GridView添加光棒效果
e.Row.Attributes.Add("onmouseover",
"currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699ff'");
e.Row.Attributes.Add("onmouseout",
"this.style.backgroundColor=currentcolor");
1.GridView的多选效果(注意一个字都不要错才能运行)
(1)先在JavaScript中写代码:
<head runat="server">
<script
language="javascript">
function GetAllCheckBox(CheckAll)
{
var items=document.getElementsByTagName_r("input");
for(i=0;i<items.length;i++)
{
if(items[i].type=="checkbox")
{
items[i].checked=CheckAll.checked;
}
}
}
</script>
<title>无标题页</title>
(2)在控件的onclick事件中写代码(即使控件没有这个事件,也要硬写上去)
<asp:CheckBox ID="chkCheckAll" runat="server"
Text="全选"
onclick="javascript:GetAllCheckBox(this)"/>
2.GridView的光棒效果:——要在它的行绑定事件中写:里面注释的即是。
//GridView的行绑定事件
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState
== DataControlRowState.Alternate)
{
//关于多选框
CheckBox box =
(CheckBox)e.Row.Cells[7].FindControl("CboxSelect");
if (MessageManager.IDList != null)
{
if (MessageManager.IDList.Contains( box.Text))
{
box.Checked =
true;
}
}
//为GridView添加光棒效果
e.Row.Attributes.Add("onmouseover",
"currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699ff'");
e.Row.Attributes.Add("onmouseout",
"this.style.backgroundColor=currentcolor");
相关文章推荐
- js弹出窗体——控制下拉条的是否显示…
- SQL函数
- 生日提醒
- Android 如何监听返回键,弹出一个退出对话框
- 世界是客观存在的吗?
- 宏
- 蓝桥杯 入门训练 Fibonacci数列
- [Android Studio 权威教程]AS添加第三方库的6种方式(Jar,module,so等)
- C++中各种类型的成员变量的初始化方法(mark-好)
- Java排序算法(六)--冒泡排序(交换排序)
- mysql error:Table 'performance_schema.session_variables' doesn't exist
- JQuery实现选项卡效果
- 改变dede图片上传路径(商品-缩略图)去掉/allimg/ymd/
- mysql replace()函数
- dede 单页文章放根目录下方法
- dede 完美分页效果! pagelist修改
- 不同浏览器字符间距不同原因。font-size和 font-family,
- 控制dede 留言板 显示条数。
- div与span区别及用法
- apache conf Order Allow,Deny