如何在DataGrid中点击任意一行实现此行的选取功能?
解决方案 »
- oledb连接数据库access出现问题????
- 在框架页中点击按钮回到登录框的同时关闭框架页的问题
- 如何单击Table的任意位置,取出该单元格内的值啊
- gb2312与utf_8的字符集有什么区别?
- ListBox问题~!
- 新建一C#&J2ME群,群号:14298180 欢迎各位大侠光临.UP有分...
- 怎样使用 HtmlInputFile 一次上传多个文件???
- 请问有关js的脚本....老大们帮帮忙啊
- 奇怪的解密!!
- 请教老鸟:如果简单的去做在线人数统计和在线会员显示?asp.net(vb)
- asp.net项目下页面上所有的按钮都突然无效了,微软最后价值的开发工程师们,帮我解决了,200分送给第一个解决的人
- 能否将一个文本文件存放在内存中?
在OnPreRender(..)
里添加
foreach(DataGridItem dgi in yourDataGrid.Items)
{
int intII = dgi.ItemIndex + 2 ;
string str = "__doPostBack('yourDataGrid$_ctl"+intII.ToString()
+"$_ctl0','')";
dgi.Attributes.Add("onclick",str);
}
private void DataGrid1_ItemDataBound_1(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onclick","javascript:ChangeRowColor(this)");
e.Item.Attributes.Add("ondblclick","javascript:getData(this,"+e.Item.Cells[0].Text+")");
}
}前台的javascriptvar oldRow="";
function ChangeRowColor(rowObj)
{
if(oldRow=="")
{
oldRow=rowObj;
oldRow.style.backgroundColor='white';
rowObj.style.backgroundColor='#FEE6A7';
}
if(oldRow!=rowObj)
{
oldRow.style.backgroundColor='white';
rowObj.style.backgroundColor='#FEE6A7';
oldRow=rowObj;
}
}
function getData(rowObj,ID)
{
ChangeRowColor(rowObj);
var getControl=window.showModalDialog("HepatitisCheckCardView_p.aspx",ID,"dialogWidth=800px;dialogHeight=300px");
}