; this.grdContent.DataSource = ds.Tables[0]; this.grdContent.DataBind(); } 最后我们需要在该DataGrid绑定数据的时候做点什么,下面是我们做的事情,代码如下: private void grdContent_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { e.Item.Attributes.Add("onmouseover", "this.bgColor='#f1f1f1'"); e.Item.Attributes.Add("onmouseout", "this.bgColor='#ffffff'"); e.Item.Attributes.Add("onclick", "GetRowData('"+this.TextBox1.ClientID+"',this,1)"); } 我们首先需要给用户一个醒目的鼠标移动的效果所以我们使用将onmouseover和onmouseout指定到tr对象上,之后我们将给tr编写onclick 事件相应所要激发的函数。(tr是DataGrid呈现在客户页码:[1] [2] [3] [4] [5] [6] [7] 第6页、共7页 |