日期:2014-05-19  浏览次数:20476 次

急!!!如何用脚本获取DataGrid中的值
我想用脚本获取DataGrid中Cell[4]中的值怎么办啊?

------解决方案--------------------
你有哪些东西了?
知道datagrid的clientid么?
知道的话直接
document.getElementById(datagridid)[0][3].value
这就是第一行第四列的值。
------解决方案--------------------
同上
------解决方案--------------------
private void dg1_ItemDataBound(object sender ,System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if((e.Item.ItemType == ListItemType.Item)||(e.Item.ItemType == ListItemType.AlternatingItem)||(e.Item.ItemType == ListItemType.SelectedItem))
{
e.Item.Attributes[ "onclick "]= "javascript:document.all.hidden1.value= ' "+e.Item.Cells[4].Text.Replace( "  ", " ")+ " ' ";
}
}
------解决方案--------------------
DataGrid 在运行 前台页面实际为table 你用js 去操作table 取指定行列值就可以了.
------解决方案--------------------

<script language= "javascript ">
var vl;
vl=document.getElementById( "DataGrid1 ").rows[0].cells[3].innerText;
alert(vl);
</script>

其中sss 为datagrid 转变为table后的ID号,这个值你自己决定。rows[0] 1行。cells[3] 第4列。