这对我很有难度,解决不了.希望各位高手能帮助指导下~~谢谢~
希望大家各抒自见~~
[此贴子已经被作者于2007-8-3 11:35:03编辑过]
在前台的页面加上JS脚本:如
<script type="text/javascript">
var currentRowId = 0;
function SelectRow()
{
if (event.keyCode == 40)
MarkRow(currentRowId+1);
else if (event.keyCode == 38)
MarkRow(currentRowId-1);
}
function MarkRow(rowId)
{
if (document.getElementById(rowId) == null)
return;
if (document.getElementById(currentRowId) != null )
document.getElementById(currentRowId).style.backgroundColor = '#ffffff';
currentRowId = rowId;
document.getElementById(rowId).style.backgroundColor = '#ff0000';
}
</script>
在后台添加一下index变量的声明,和在Gridview的RowDataBound绑定事件里写,如:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("id",index.ToString());
e.Row.Attributes.Add("onKeyDown", "SelectRow();");
e.Row.Attributes.Add("onClick", "MarkRow(" +index.ToString() + ");");
index++;
}
}
这个是DataView的选中行后激发的事件,当选择行后Image_query响应的图片ImageUrl 是指向ShowPhoto.ashx这个资源文件,图片是否能正常显示,这主要看你ShowPhoto.ashx生成的图片了.
[此贴子已经被作者于2007-8-3 14:31:33编辑过]
不用在SelectRow函数里写什么东西,你只在DataView的这个SelectedIndexChanged事件加上这两句代码就行了.
protected void gv_QueryProduct_SelectedIndexChanged(object sender, EventArgs e)
{
string graphcode = gv_QueryProduct.SelectedDataKey.Value.ToString();
this.Image_query.ImageUrl = "~/ProductManagement/ShowPhoto.ashx?graphcode=" + graphcode;
}