DataGrid中加多选按钮 和 鼠标移动显示不同的颜色
2010-10-19 16:21
501 查看
一、
aspx文件中加
<script language="javascript">
<!--
//CheckBox全选And反全选
function select_deselectAll (chkVal, idVal)
{
var frm = document.forms[0];
for (i=0; i<frm.length; i++)
{
if (idVal.indexOf ('CheckAll') != -1)
{
if(chkVal == true)
{
frm.elements[i].checked = true;
}
else
{
frm.elements[i].checked = false;
}
}
else if (idVal.indexOf('DeleteThis') != -1)
{
if(frm.elements[i].checked == false)
{
frm.elements[1].checked = false;
}
}
}
}
//-->
</script>
全选<input id="CheckAll" onclick="return select_deselectAll (this.checked, this.id)" tabIndex="0" type="checkbox" title="点击全选或反全选当前页所有信息">
DataGrid中加模板列
<asp:TemplateColumn HeaderText="选定">
<HeaderStyle Width="10%"></HeaderStyle>
<ItemTemplate>
<asp:CheckBox id="chkSelectBox" runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
CS文件中操作选定项
foreach (DataGridItem item in DataGrid.Items)
{
if(((CheckBox)item.FindControl("chkSelectBox")).Checked==true)
{
Response.Write (item.Cells[0].Text);
}
}
二、
核心代码:
private void grdCustomer_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.AlternatingItem ||
e.Item.ItemType == ListItemType.Item )
{
e.Item.Attributes.Add("onmouseover", "this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='#C8F7FF'");
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=this.oldcolor");
for (int i = 0; i< grdCustomer.Columns.Count; i++ )
{
e.Item.Cells[i].Attributes.Add("onmouseover",
"this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='#99ccff'");
e.Item.Cells[i].Attributes.Add(
"onmouseout", "this.style.backgroundColor=this.oldcolor");
}
}
}
aspx文件中加
<script language="javascript">
<!--
//CheckBox全选And反全选
function select_deselectAll (chkVal, idVal)
{
var frm = document.forms[0];
for (i=0; i<frm.length; i++)
{
if (idVal.indexOf ('CheckAll') != -1)
{
if(chkVal == true)
{
frm.elements[i].checked = true;
}
else
{
frm.elements[i].checked = false;
}
}
else if (idVal.indexOf('DeleteThis') != -1)
{
if(frm.elements[i].checked == false)
{
frm.elements[1].checked = false;
}
}
}
}
//-->
</script>
全选<input id="CheckAll" onclick="return select_deselectAll (this.checked, this.id)" tabIndex="0" type="checkbox" title="点击全选或反全选当前页所有信息">
DataGrid中加模板列
<asp:TemplateColumn HeaderText="选定">
<HeaderStyle Width="10%"></HeaderStyle>
<ItemTemplate>
<asp:CheckBox id="chkSelectBox" runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
CS文件中操作选定项
foreach (DataGridItem item in DataGrid.Items)
{
if(((CheckBox)item.FindControl("chkSelectBox")).Checked==true)
{
Response.Write (item.Cells[0].Text);
}
}
二、
核心代码:
private void grdCustomer_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.AlternatingItem ||
e.Item.ItemType == ListItemType.Item )
{
e.Item.Attributes.Add("onmouseover", "this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='#C8F7FF'");
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=this.oldcolor");
for (int i = 0; i< grdCustomer.Columns.Count; i++ )
{
e.Item.Cells[i].Attributes.Add("onmouseover",
"this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='#99ccff'");
e.Item.Cells[i].Attributes.Add(
"onmouseout", "this.style.backgroundColor=this.oldcolor");
}
}
}
相关文章推荐
- 在DataGrid中,使鼠标到达的行和列显示不同的颜色
- datagrid的几点简单应用,功能包括radio的单选,checkbox的多选,鼠标移动到行上颜色变深,链接传递多参数等功能。这里radio和checkbox都使用的是HTML控件。
- 在DataGrid中,使鼠标到达的行和列显示不同的颜色
- DataGrid鼠标指向时显示不同颜色
- 在DataGrid中,使鼠标到达的行和列显示不同的颜色
- 在DataGrid中,使鼠标到达的行和列显示不同的颜色 (转载)
- DataGrid鼠标到达的行和列显示不同的颜色
- winform中dataGridView隔行显示不同的背景色,鼠标移动上显示不同颜色,离开后变回原色
- DataGrid鼠标到达的行和列显示不同的颜色
- DataGrid鼠标到达的行和列显示不同的颜色
- DataGrid鼠标到达的行和列显示不同的颜色
- DataGrid鼠标指向时显示不同颜色
- 当鼠标移动时,改变datagrid中的颜色
- 鼠标覆盖行高亮显示 奇偶行背景颜色不同 css+jquery Table
- DataGrid实现过多信息鼠标移动到记录上显示,可分页
- HTML route点击不同按钮,显示不同内容,可以改变按钮背景颜色
- (10)JS之按下不同的按钮显示不同的颜色
- WPF 设置DataGrid 鼠标移动改变行颜色样式
- 设置WPF DataGrid 鼠标移动改变行颜色样式
- 在使用Repeater、DataList 或 DataGrid 的模板列表时,根据不同状态,显示不同颜色