读书人

GridView有关问题

发布时间: 2012-02-17 17:50:42 作者: rapoo

GridView问题,请教高手
GridView绑定了数据源后(GridView的字段为HyperLinkField),现在需要点击一下这个字段后,先得到这个字段的数据,然后再不刷新页的情况下,改变画面Iframe的内容。

protected void MyGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
string strOnClick= " ",strReadFile;
if (e.Row.RowType == DataControlRowType.DataRow)
strOnClick = ((HyperLink)e.Row.Cells[0].Controls[0]).Text;
strReadFile = "document.frames[ 'htmlLook '].document.location = 'file/ " + strFileName + " ' ';document.reflash(100);return false; ";

(HyperLink)e.Row.Cells[1].Controls[0]).Attributes.Add( "Onclick ", strReadFile );
}

现在的问题是,点击一下字段后,strOnClick会一次把一页(10条)记录的值各读一遍。应该怎么办?

[解决办法]
protected void MyGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
string strOnClick= " ",strReadFile;
if (e.Row.RowType == DataControlRowType.DataRow)
strOnClick = ((HyperLink)e.Row.Cells[0].Controls[0]).Text;
if (strTitle != null || strTitle != " ")//GridView前后会读出空白,在下面加判断后读数据就行
{
}


strReadFile = "document.frames[ 'htmlLook '].document.location = 'file/ " + strFileName + " ' ';document.reflash(100);return false; ";


(HyperLink)e.Row.Cells[1].Controls[0]).Attributes.Add( "Onclick ", strReadFile );
}

读书人网 >asp.net

热点推荐