http://dotnet.aspx.cc/ShowDetail.aspx?id=19BE9FAC-437A-4863-910D-9427554561B2
解决方案 »
- sql2005联机帮助是通过webservice获取的吗?发现其响应速度超快,比在IE下打开相应网页快多了。请详细解析一下。
- 图片滚动的问题!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- 为什么服务器iis过一段就会报错呢?
- 对上海IDC机房了解的朋友帮忙,请教拖管问题
- Developer Express.NET 控件引用的问题.使用过的高手进
- 在TextBox输入框中输入字符串后自动刷新搜索的问题
- ASP.NET入门
- 在aspx中包含IFRAME 的问题
- 急!!!一个session的问题?
- 关于usercontrol的问题
- SQLSERVER数据库文件MDF,最大可以大到多少?
- treeview的样式问题,见鬼了!!!
http://blog.mvpcn.net/cuike519/archive/2004/05/04/1276.aspx
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+")");//e.Item.Cells[0].Text取当前行第一列的值(双击当前行时)
}
}客户端代码
<script language="javascript">
var oldRow="";
function ChangeRowColor(rowObj)//改变当前DataGrid中所选行的颜色
{
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");
}
</script>
然后定义一个方法就可以了
private string GetSelected(int i)
{
foreach(DataGridItem di in DataGrid1.Items)
{
if(((CheckBox) di.FindControl("cb")).Checked)
{
retrun di.Cell[i].Text.Tostring();
}
}
}
magiccoder的方法,我没有找到调用DataGrid1_ItemDataBound_1的地方。
dxphero的方法,我加不上模板列checkbox cb。只能加上按钮的模板列。
各位仁兄,还有没有人有办法啊,小弟急死了!